webdriver - Selenium-Onclick() JavaScript issue -
following source code select radio button having javascript onclick()
method.
<span class="adcontrols"> <input id="rdbtnpreviousdate" name="date" value="rdbtnpreviousdate" onclick="javascript:settimeout('__dopostback(\'rdbtnpreviousdate\',\'\')', 0)" type="radio"/> <label for="rdbtnpreviousdate">27-jul-2017</label> </span>
i tried following none of code run successfully.
1) wbd.findelement(by.cssselector("input[id=rdbtnpreviousdate]")).click();
2) wbd.findelement(by.cssselector("input[value=rdbtnpreviousdate]")).click();
3)
wbd.findelement(by.xpath("html/body/form/table[2]/tbody/tr[1]/td[2]/span[1]/input")).click();
4) wbd.findelement(by.xpath("//[class='adcontrols'][@id='rdbtnpreviousdate']]")).click();
5)
wbd.findelement(by.cssselector("input[onclick=javascript:settimeout('__dopostback(\'rdbtnpreviousdate\',\'\')', 0)]")).click();
6)
webelement input = wbd.findelement(by.id("rdbtnnextdate")); new actions(wbd).movetoelement(input).click().perform();
some of errors:
exception in thread "main" org.openqa.selenium.nosuchelementexception: unable locate element: #rdbtnnextdate exception in thread "main" org.openqa.selenium.invalidselectorexception: given css selector expression "input[onclick=javascript:settimeout('__dopostback('rdbtnpreviousdate','')', 0)]" invalid:
try execute simple javascript(jquery) select radio button
wbd.executescript("$('input[id=rdbtnpreviousdate]').click()");
Comments
Post a Comment