javascript - how can i locate a input element of radio and check it ?always "Unable to find element " -
i learning selenium c# ,i trying input element of radio,but "unable find element "
<div> <span id="ctl00_contentplaceholder1_ucobservationsearch1_rbladvancedsearch" class="radiolistoptions"> <input id="ctl00_contentplaceholder1_ucobservationsearch1_rbladvancedsearch_0" type="radio" checked="checked" value="my" name="ctl00$contentplaceholder1$ucobservationsearch1$rbladvancedsearch"> <label for="ctl00_contentplaceholder1_ucobservationsearch1_rbladvancedsearch_0">my</label> <br> <input id="ctl00_contentplaceholder1_ucobservationsearch1_rbladvancedsearch_1" type="radio" onclick="javascript:settimeout('__dopostback(\'ctl00$contentplaceholder1$ucobservationsearch1$rbladvancedsearch$1\',\'\')', 0)" value="workgroup" name="ctl00$contentplaceholder1$ucobservationsearch1$rbladvancedsearch"> <label for="ctl00_contentplaceholder1_ucobservationsearch1_rbladvancedsearch_1">workgroup</label> <br> <input id="ctl00_contentplaceholder1_ucobservationsearch1_rbladvancedsearch_2" type="radio" onclick="javascript:settimeout('__dopostback(\'ctl00$contentplaceholder1$ucobservationsearch1$rbladvancedsearch$2\',\'\')', 0)" value="division" name="ctl00$contentplaceholder1$ucobservationsearch1$rbladvancedsearch"> <label for="ctl00_contentplaceholder1_ucobservationsearch1_rbladvancedsearch_2">division</label> </span> </div>
i have tried
readonlycollection<iwebelement> links1 = driver.findelements(by.xpath("//input[contains(text(),'workgroup')]")); readonlycollection<iwebelement> links1 = driver.findelements(by.xpath("//input[contains(@value,'workgroup')]")); iwebelement check = driver.findelement(by.id("ctl00_contentplaceholder1_ucobservationsearch1_rbladvancedsearch_1"));
and have tried in console javascript
document.getelementbyid("ctl00_contentplaceholder1_ucobservationsearch1_rbladvancedsearch_1").checked=true
return "typeerror: document.getelementbyid(...) null" have no more solution ,i need ,thanks
i find there 1 more html in html,maybe that's why fail,anyone knows how deal it?
try ..
document.addeventlistener("domcontentloaded", function (event) { document.getelementbyid("ctl00_contentplaceholder1_ucobservationsearch1_rbladvancedsearch_1").checked = true; });
Comments
Post a Comment