Watir: How can I execute in a watir script a specific javascript function called

原地址 http://stackoverflow.com/questions/6051786/watir-how-can-i-execute-in-a-watir-script-a-specific-javascript-function-called

 

Question

 

 

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 `method_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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值