I am trying to test a webpage in selenium that is created using angularjs. On this page are a text fields the user will fill out. As the user is typing in the text fields angular will pickup every keystroke and display a preview on the fly exactly how filling out a stackoverflow question generates a preview. :)
My issue is I cannot figure out how to test it. If I click on the text field and type it works. I have tried, the selenium type command, typeKeys command, using the mousedown and mouseup command and then typeKeys to try to mimic a user typing. But they are not working as if there are event handlers not being triggered. I need to mimic the way a human types so the events will trigger. This is what I am thinking but it doesn’t work.
<tr>
<td>mouseDown</td>
<td>name=appName</td>
<td></td>
</tr>
<tr>
<td>mouseUp</td>
<td>name=appName</td>
<td></td>
</tr>
<tr>
<td>typeKeys</td>
<td>name=appName</td>
<td>foobar</td>
</tr>
If there is a way using javascript that will be acceptable too. Thanks.
I was having the same issue with testing Angular JS form fields using Selenium IDE. I tried just about every known combination of focus, click, clickAt, keypress, etc. Finally found that what worked was using the sendKeys command to put the text into the field. So in Selenium-IDE, the command was
sendKeys | xpath=(//input[@type='text'])[2] | TEXT To Enter
Note that I used the xpath, but it didn't matter what I used to identify the target (css=, xpath, //div), any of the identifiers worked, it just took using sendKeys to do the trick.
Try either the focus or click commands.