Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Webdriver sendkeys does not trigger onchange event in IE9.0

I'm writing Selenium test scripts using Java for an application built in ExtJs. I have an input field in one of the page which is attached to 'onchange' event. Whenever user modifies the text in the field, onchange event is triggered. I'm using WebDriver sendKeys() to modify the text in the field. So whenever text is modified, 'onchange' event is triggered in Firefox and Chrome (as expected) but its not getting triggered in IE9.0. I have searched all over the net for the solution, but didn't find one. So please can someone help me on this? Let me know more info is required

like image 345
Muthu Avatar asked Jul 22 '13 19:07

Muthu


People also ask

Why sendKeys is not working in Selenium?

sendKeys() not working in Selenium WebdriverSelenium can run JavaScript commands with the help of the executeScript method. JavaScript command to be used is passed as a parameter to this method. To input text we shall first identify the edit field with the JavaScript method document. getElementsByClassName.

What can I use instead of sendKeys?

New Selenium IDE We can input text in the text box without the method sendKeys with thehelp of the JavaScript Executor. Selenium executes JavaScript commands with the help of the executeScript method.


1 Answers

You can either click on a different element on the field, or perhaps the easier way is to tab off of the field after the input is finished.

In the ExtJS applications I've automated, I'll always tab off of the field after performing the input, which fires all of the correct events.

Using C# as an example:

IWebElement element = driver.FindElement(By.Id("some_input_field"));
element.SendKeys("test input")
element.SendKeys(Keys.Tab);
like image 58
Nathan Dace Avatar answered Nov 15 '22 09:11

Nathan Dace