Reputation: 65
I want to execute javascript using selenium.
JavaScript code on UI:
<input id="rbSingleFuture" class="rfdRealInput" type="radio" onclick="javascript:setTimeout('__doPostBack(\'rbSingleFuture\',\'\')', 0)" value="rbSingleFuture" name="PaymentTypeGrp" _rfddecoratedid="_rfdSkinnedrbSingleFuture"></input>
My code:
IJavaScriptExecutor js = (IJavaScriptExecutor)_webDriver;
js.ExecuteScript("onclick=javascript:setTimeout(__doPostBack('rbSingleFuture',''), 0);");
This does not clicks on the radio button.
Upvotes: 0
Views: 1606
Reputation: 31
Try this
IJavaScriptExecutor js = (IJavaScriptExecutor)_webDriver;
js.ExecuteScript("document.getElementById('rbSingleFuture').click();");
Source: http://www.w3schools.com/jsref/met_html_click.asp
Upvotes: 1