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
I faced the same issue but able to resolve this issue. Below code is for enter text in input field and fire onchange event.
WebElement textBox = driver.findElement(By.xpath(xpath));
textBox.sendKeys("Test");
((JavascriptExecutor) driver).executeScript("arguments[0].onchange",
Arrays.asList(textBox));
Hope it will work!
I had a similar problem, with a Dropdown list made with Ajax.
As the user types in a field, the system displays AJAX div
w with several options, each one as a link with target='#'
And even worse, there was a function called on the onChange() that filled a system flag, and that flag would be used as a validation on the form.submit() (oh, the pain)
Anyways, my solution for this:
1 - Selenium sendKeys command so the Ajax div would appear
<tr>
<td>sendKeys</td>
<td>id=txtTipoDocumento</td>
<td>ipsum lorem</td>
</tr>
2 - wait for the link with the expected option to appear
<tr>
<td>waitForElementPresent</td>
<td>link=ipsum lorem</td>
<td></td>
</tr>
3 - selenium clickAt the link
<tr>
<td>clickAt</td>
<td>link=ipsum lorem</td>
<td>10,20</td>
</tr>
4 - Here is the ONE of the catches: manually fire the onChange() AND blur events. Also, foce the browser to set focus on different field
<tr>
<td>fireEvent</td>
<td>id=txtTipoDocumento</td>
<td>blur</td>
</tr>
<tr>
<td>fireEvent</td>
<td>id=selSerie</td>
<td>change()</td>
</tr>
<tr>
<td>fireEvent</td>
<td>id=selSerie</td>
<td>blur</td>
</tr>
<tr>
<td>focus</td>
<td>id=imgDataElaboracao</td>
<td></td>
</tr>
5 - Finally, to be sure, I made Selenium do execute the ClickAt() command on the Submit button of the forme, between a mouseDown and MouseUp commands
<tr>
<td>mouseDown</td>
<td>id=btnSalvar</td>
<td></td>
</tr>
<tr>
<td>focus</td>
<td>id=btnSalvar</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>id=btnSalvar</td>
<td>10,20</td>
</tr>
Not elegant, but it worked.