开发者

Watir: How can I execute in a watir script a specific javascript function called on select of a checkbox?

开发者 https://www.devze.com 2023-03-06 17:31 出处:网络
In a Watir script, after I check checkboxes in a popup window, I\'m trying to execute a javascript function to add objects selected to the parent window.

In a Watir script, after I check checkboxes in a popup window, I'm trying to execute a javascript function to add objects selected to the parent window.

What works fine until now it is the check of the checkbox, but object is not added to the parent window and I get following error when I executed the watir script: in `met开发者_运维百科hod_missing': execScript (WIN32OLERuntimeError)

This was my approach - please let me know what other method I can use

ie.checkbox(:id => "check_asm0option0").set 
ie.document.parentWindow.execScript("window.triggerOriginalChange(asm0option0, add);","JavaScript") 

tr class="tr_option" rel="asm0option0"
td class="td_check"
input id="check_asm0option0" type="checkbox" value="4dbb118ddca3244e2800003d" rel="asm0option0" name="ignore"
/td
td class="td_li"
li value="0" rel="asm0option0" test /li
/td
/tr


if using .set doesn't result in your code working the way you'd expect, then examine the source and then try using .fireEvent to fire the event that should trigger the script that needs to execute.

In this case I'd try

ie.checkbox(:id => "check_asm0option0").fireEvent('onChange')

that approach is generally a bit more organic and easier than trying to invoke the script manually

0

精彩评论

暂无评论...
验证码 换一张
取 消