I have using selenium webdriver 2.33.0 and i have a requirement of sending data with the following characters inside the data ("(", "#")
When we tried to send these characters using sendkeys
"WebElement dat = driver.findElement(By.xpath("xpathexpression);
dat.sendkeys("select * from (?s, ?p, ?o)");
The following data gets displayed in the textarea as select * from ?s, ?p, ?o)
the open bracket is missing. I have used selenium actions class sendkeys and robot sendkeys also.
I am not able to fix the issue. Can someone help me on this?
Ugly but efficient workaround: replace the opening brackets ( with the key sequence shift + 9, as suggested by user2935099.
dat.sendKeys(Keys.chord(Keys.SHIFT, "9"));
Funnily, this seems to work regardless of your current keyboard layout (I use an Irish locale with a French layout).
I stumbled upon this one with version 2.40.0, and it is definitely a bug in Selenium. Using the following in the Firefox JavaScript console works flawlessly:
var box = getElementById('SearchBox');
box.setValue('AB (CDE FGH)');
The issue is resolved when using actions class
WebElement dat = driver.findElement(By.xpath("xpathexpression");
dat.click();
Actions data = new Actions(driver);
data.sendKeys(Keys.chord(Keys.CONTROL,"a"),Keys.DELETE);
data.perform();
query = query.replaceAll("\\(", Keys.chord(Keys.SHIFT,"9"));
query = query.replaceAll("\\#", Keys.chord(Keys.SHIFT,"3"));
query = query.replaceAll("\\-", Keys.SUBTRACT.toString());
query = query.replaceAll("\\}", Keys.chord(Keys.SHIFT,"]"));
data.sendKeys(query);
data.perform();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With