Cannot sendKeys to Div in Internet Explorer

248 views
Skip to first unread message

rscruicksh...@gmail.com

unread,
Jun 2, 2016, 11:18:09 AM6/2/16
to Selenium Users


I'm having an issue with InternetExplorerDriver in Selenium WebDriver. The image below shows part of a Sharepoint site, with Audience Area and Location as fields which can either accept a manually typed input or a choice from a popup list on clicking the button at the far right of the field. In the example below, I have manually input an invalid entry in Audience Area and a valid entry in Location.


However, when running scripts in Selenium, the sendKeys command does not work on these elements. According to the xpath, these elements are identified as divs with the following properties:


<div id="AudienceArea_$containereditableRegion"

 class="ms-rtestate-write ms-taxonomy-writeableregion ms-inputBox ms-inputBoxActive"

 contenteditable="true"

 role="textbox"

 aria-autocomplete="both"

 aria-haspopup="true"

 aria-multiline="true"

 disableribboncommands="True"

 allowmultilines="false"

 restrictpastetotext="True"

 rtedirty="false">



The most recent attempt to code sending text to the element is as below:


Webelement element = driver.findElement(By.xpath("//html/body/form/div[4]/div/div[1]/div/div[2]/div[2]/div[2]/table/tbody/tr/td/div/div/div/div/table/tbody/tr/td[1]/span/table[1]/tbody/tr[5]/td[2]/div/div[1]/div/div"));

Actions actions = new Actions(driver);

actions.moveToElement(element);

actions.click();

actions.sendKeys("SomeText");

actions.build().perform();


When I run this in Firefox it identifies the element and sends the required text. When I attempt this in Internet Explorer, it successfully identifies the element and performs sendKeys, but nothing appears in the text field. No exception is returned.


Has anyone encountered anything like this before? Is there a way around this, such as an alternative to sendKeys?


I am running InternetExplorerDriver v2.53.1.0 with IE v11



rscruicksh...@gmail.com

unread,
Jun 2, 2016, 11:29:31 AM6/2/16
to Selenium Users
I should add that I have also tried using JavascriptExecutor as follows:

JavascriptExecutor rightexecutor = (JavascriptExecutor)driver;
rightexecutor.executeScript("arguments[0].setAttribute('innerHTML','SomeText')", element) 

This also failed to yield any results.

Andrew Jervis

unread,
Jun 3, 2016, 6:34:30 AM6/3/16
to Selenium Users
I have encountered a similar issue with sendkeys in Firefox which might help

Try the line below

driver.findElement(By.id("acOriginAirport")).sendKeys(new String[] {"London Luton LTN"});

However, I used the above in Firefox and I understand your issue is in IE: Give it a try
Reply all
Reply to author
Forward
0 new messages