I am typing some value, on change do a total. But somehow, this event is not getting fired with selenium type command.
I also tried typeKey and typeAt ..But no succe
It looks like the "sendKeys" command was implemented to rectify this:
https://code.google.com/p/selenium/issues/detail?id=5451
This worked for me.
<tr>
<td>sendKeys</td>
<td>id=Quantity</td>
<td>Type stuff here</td>
</tr>
Firefox has a bug which prevents some events from being executed while the browser window is out of focus. This could be an issue when you're running your automation tests - which might be typing even if the window is out of focus.
To fix this issue I triggered the change event "manually", injecting javascript into my tests.:
//suppose "element" is an input field
element.sendKeys("value");
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("$(arguments[0]).change();", element);
As you might have noticed, I'm using jQuery to trigger the change event. If you're not using jQuery on your app, you can check here how to trigger it using vanilla javascript.
Hope that helps somebody.
If you're using Selenium 1.x, there is a fireEvent command that you can use to manually trigger the onChange event after typing in the value. Maybe that would solve your problem?
This worked for me in IDE do the following 3 commands in order
Typekeys targetID input
FireEvent targetID focus
Type targetID input
The source looks like this (input was letter r
)
<tr>
<td>typeKeys</td>
<td>//form/input</td>
<td>r</td>
</tr>
<tr>
<td>fireEvent</td>
<td>//form/input</td>
<td>focus</td>
<tr>
<td>fireEvent</td>
<td>//form/input</td>
<td>focus</td>
</tr>
<tr>
<td>type</td>
<td>//form/input</td>
<td>r</td>
</tr>
</tr>
<tr>
<td>type</td>
<td>//form/input</td>
<td>r</td>
</tr>
To trigger the onchange event, try adding this command in Selenium IDE:
fireEvent targetID blur
Your solution normally is found by looking at the JavaScript code..
An option you always have is to put in the value and manually trigger the actual OnChange event from code.
There are an open issue about this link text Problem with FireFox Windows not being active and prevents the OnChange to be triggered.
Try this before using typeKeys command:
selenium.selectWindow(null);