2

I'm using Selenium to perform testing on BrowserStack, and have hit a problem while testing IE8.

I've found that when I target elements and then call Click, the full effect of the action is not being undertaken*.

Through trial-and-error I found that if I call Click twice then the expected action is undertaken.

However, one of the testing steps involves writing a number to a text field, and for this I have the following:

driver.FindElement(By.CssSelector("...")).Click();
driver.FindElement(By.CssSelector("...")).Clear();
driver.FindElement(By.CssSelector("...")).SendKeys(Keys.NumberPad1);
driver.FindElement(By.CssSelector("...")).Click();

But "1" never appears in the field. I can tell it never appears because I'm capturing screenshots after each step; I can see that the field gets highlighted (as the active element) and I can see the cursor inside the field, but no result from the method call.

Furthermore, I've even tried giving the field an ID and addressing it with

driver.FindElement(By.Id("txtCountManual")).SendKeys(Keys.NumberPad1);

But with the same (lack of) results.

Does anyone have any suggestions as to how I may send a textual value to a field in IE8 using Selenium and BrowserStack?

 

* The "expected action" involves using Knockout.js to display a selected value in another element. So for example, I found that if I programmatically click a radio button and then take a screenshot, I can see that the radio button has been clicked but the action performed by Knockout.js has not taken place; if I click the element a second time then the Knockout.js action is performed. This double-clicking is not required when I manually test using IE8 via BrowserStack.

awj
  • 7,482
  • 10
  • 66
  • 120
  • Try printing the text from the field by using `driver.FindElement(By.Id("txtCountManual")).getAttribute("value")` and check if you get empty or the value you input using Keys. – Harish Jul 26 '16 at 15:44
  • It returns an empty value. – awj Jul 26 '16 at 15:47
  • Send a click event to the input field before using sendKeys method. Hope it helps. – Harish Jul 26 '16 at 15:50
  • As you can see from the code in the OP, I *am* sending a click event to the input field before using sendKeys method. Furthermore, I also send one afterwards. It doesn't help. – awj Jul 26 '16 at 15:51
  • After sending clear event, use click event. I had observed similar issue long back in IE browser and it did work for me. Still if it doesn't work, you can use javascript to enter the value. – Harish Jul 26 '16 at 16:02
  • You're right about using JavaScript - that's what I've implemented for now, but I'm still hoping someone can provide a definitive answer here to explain things because the JS solution seems a bit hack-ey. – awj Jul 26 '16 at 16:03
  • Yes JS is bit hacky. I have seen many users reporting the same issue. Appears to be some bug with IE driver. I haven't been able to find the definitive answer/solution. – Harish Jul 26 '16 at 16:05
  • One more solution I found is using Actions class. `Actions act = new Actions(driver); act.sendKeys(element, "InputValue").perform()`. – Harish Jul 27 '16 at 09:05

0 Answers0