I am taking selenium web driver course on test automation university. On chapter 6, the instructor is using mac and is able to send the pi symbol using the following:
public void enterPi(){
enterText(Keys.chord(Keys.ALT, "p") + "=3.14");
}
but on windows, I have to hold the alt button and press on 227 on the numpad.
I have tried both chrome and edge drivers but still not working.
This is the fuction I am using:
public void enterText(String text){
driver.findElement(formInput).sendKeys(text);
}
and I tried 3 options as following with actual result I got:
option 1:
enterText(Keys.chord(Keys.ALT, "227") +"=3.14");
got the following:
enter image description here
option 2:
enterText(Keys.chord(Keys.ALT, Keys.NUMPAD2, Keys.NUMPAD2, Keys.NUMPAD7) +"=3.14");
got the following:
enter image description here
option 3: doesn’t use the enterText function
new Actions(driver).keyDown(Keys.ALT).sendKeys("227").perform();
enter image description here
Ahmad Soliman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.