Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
59
rated 0 times [  66] [ 7]  / answers: 1 / hits: 45723  / 13 Years ago, mon, march 28, 2011, 12:00:00

I'm building and automated test script for a webapp using selenium and I'm trying to use the waifForCondition function of the API where it will wait until a JS script evaluates to true.



I currently have this source on the page:



<input id=modifyHostsForm:idDnsIp0_0 type=text name=modifyHostsForm:idDnsIp0_0 readonly= disabled=>


Which should change to:



<input id=modifyHostsForm:idDnsIp0_0 type=text name=modifyHostsForm:idDnsIp0_0>


As soon as I put a certain value on another field and fire the blur event on it (and this field thus becomes enabled).



And I'm trying to execute the following JS script to test when this field is enabled (basically what I found from Googling):



document.getElementbyId('modifyHostsForm:idDnsIp0_0').disabled == false


However I'm getting a SeleniumException which indicates that Object doesn't support this property or method. What can I do here? Any help would be appreciated.


More From » input

 Answers
3

After looking into this I found the answer. I'm documenting it here in case anyone has use for it.



I was running my question code in the FireBug console and it was working correctly; however when executing my script I kept getting SeleniumException.



It turns out that you need to use selenium.browserbot.getCurrentWindow() for the RC to execute the JS script on the main window you're using instead of the control window that pops up.



As such, the JS code I actually need to evaluate ends up being this:



selenium.browserbot.getCurrentWindow().document.getElementById('modifyHostsForm:idDnsIp0_0').disabled == false


Which works just fine. Thanks for the other hints.


[#93039] Saturday, March 26, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
koltonadolfow

Total Points: 71
Total Questions: 118
Total Answers: 102

Location: Vietnam
Member since Sun, Oct 18, 2020
4 Years ago
;