0

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.

1 Answer 1

1

Try this

IJavaScriptExecutor js = (IJavaScriptExecutor)_webDriver;
js.ExecuteScript("document.getElementById('rbSingleFuture').click();");  

Source: http://www.w3schools.com/jsref/met_html_click.asp

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.