Css Selenium:无法选择单选按钮
我尝试使用selenium选择一个单选按钮,当我运行脚本selenium时,它不会选择单选按钮,并在没有选择单选按钮的情况下移动到下一步,不会给我任何错误 以下是同一版本的HTML:Css Selenium:无法选择单选按钮,css,selenium,selenium-webdriver,xpath,radio-button,Css,Selenium,Selenium Webdriver,Xpath,Radio Button,我尝试使用selenium选择一个单选按钮,当我运行脚本selenium时,它不会选择单选按钮,并在没有选择单选按钮的情况下移动到下一步,不会给我任何错误 以下是同一版本的HTML: <div class="col-12 scrolling pend active" id="mergeTransTable"> <div class="title-table transactions">
<div class="col-12 scrolling pend active" id="mergeTransTable">
<div class="title-table transactions">
<div class="expenseDetailId" style="cursor: pointer;">
<input id="hdnMergeOtherDataCount" name="hdnMergeOtherDataCount" type="hidden" value="0">
</div>
<div class="comment" style="cursor: pointer;" width="20%">Comment
<div class="vendor" style="cursor: pointer;">Vendor </div>
</div>
<div class="receipt" style="cursor: pointer;">
Receipt
</div>
</div>
<div class="data-table transactions">
<div class="expenseDetailId" data-title="ExpenseDetailId" style="margin-top:2%;">
<input type="radio" name="ExpenseDetailId" id="ExpenseDetailId" class="chk" value="163867">
</div>
<div class="vendor" data-title="Vendor">AMAZON</div>
<div class="comment" data-title="Comment" width="20%">
UBER
</div>
<div class="receipt"" data-title="Receipt">
<a id="Receipt" href="abc.com" onclick="return ViewReceipt('/ExpenseDetailId=163867')">Receipt</a>
</div>
</div>
</div>
使用CSS也没有帮助
也尝试了Java脚本和动作类,但似乎没有任何效果。Selenium只是不要选择单选按钮查看您的代码,似乎您正在“单击”
div而不是单选按钮。因此,不会发生任何事情,也不会出现错误消息。为什么不直接单击id为ExpenseDetailId
的元素
driver.findElement(By.xpath("//*[@id='mergeTransTable']/div[2]/div[1]")).click();
driver.findElement(By.xpath("//div[@id='mergeTransTable']//div[@class='expenseDetailId' or starts-with(@data-title,'ExpenseDetailId')]")).click();
driver().findElement(By.id(“ExpenseDetailId”))。单击()代码>单击输入,而不是div标记
//*[@id='mergeTransTable']/div[2]/div[1]/input
这不管用<代码>驱动程序().findElement(By.id(“ExpenseDetailId”))。单击()代码>