views:

544

answers:

1

I added this code to my web page:

<input id='argh' type='text' onfocus='this.value=7'>

Unless the browser window is active, the focus event does not seem to fire (using the 'focus' command) from Selenium:

# [info] Executing: |waitForElementPresent | argh | |
# [info] Executing: |focus | argh | |
# [info] Executing: |verifyValue | argh | 7 |
# [error] Actual value '' did not match '7'

It succeeds just fine if the window is showing during testing. Furthermore, if I activate the browser window after the above failure, #argh is focused and fills with a seven, then I go back to Selenium and rerun the line, it succeeds. (Probably obvious, but...)

What am I doing wrong? How will I be able to test things like AJAX dropdown menus from Selenium without the browser showing?

My setup is Selenium IDE 1.0.2 on Firefox 3.5.3 on win32.

+2  A: 

Does it make any difference if you use the fireEvent command?

fireEvent | argh | focus
Dave Hunt
I don't understand why, but that did the trick. Thanks!
Kev