请告诉我如何找到此脚本的xpath

时间:2016-02-22 14:12:47

标签: selenium selenium-webdriver

<div class="icheckbox-radio">
<div class="iradio_square-blue checked">
<input id="input-22" type="radio" value="OnDate" data-bind="CustomRadioBox:{checked:expiryType}" name="endradio" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"/>
<ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"/>
</div>

请告诉我们如何获取此元素的xpath。当我使用这些xpath但无法点击单选按钮时,这是一个单选按钮。 1.id.driver.findElement(By.id(&#34;输入-22&#34))点击(); 2 //输入[@数据绑定=&#39; CustomRadioBox:{检查:expiryType}&#39;和@value =&#39; OnDate&#39;]

我已将代码放在try catch块中。 enter image description here

1 个答案:

答案 0 :(得分:0)

请尝试使用JavaScript executor找到元素

WebElement OPtionButton= driver.findElement(By.id("input-22"));
JavascriptExecutor ExeCute = (JavascriptExecutor)driver;
ExeCute.executeScript("arguments[0].click();", OPtionButton);