我想使用selenium执行javascript。
UI上的JavaScript代码:
<input id="rbSingleFuture" class="rfdRealInput" type="radio" onclick="javascript:setTimeout('__doPostBack(\'rbSingleFuture\',\'\')', 0)" value="rbSingleFuture" name="PaymentTypeGrp" _rfddecoratedid="_rfdSkinnedrbSingleFuture"></input>
&#13;
我的代码:
IJavaScriptExecutor js = (IJavaScriptExecutor)_webDriver;
js.ExecuteScript("onclick=javascript:setTimeout(__doPostBack('rbSingleFuture',''), 0);");
&#13;
这不会点击单选按钮。
答案 0 :(得分:1)
试试这个
IJavaScriptExecutor js = (IJavaScriptExecutor)_webDriver;
js.ExecuteScript("document.getElementById('rbSingleFuture').click();");