gpt4 book ai didi

selenium - 从隐藏的下拉菜单中选择选项

转载 作者:行者123 更新时间:2023-12-03 16:43:24 37 4
gpt4 key购买 nike

<table id="rusTable" class="groupTable" cellspacing="0" cellpadding="0">
<tbody class="ui-sortable" style="">
<tr class="groupTop ruBorder" style="display: table-row;">
<tr id="ru0" class="siru">
<tr class="ruOp off">
<td class="first"></td>
<td colspan="3">
<select class="ruOpSelect">
<option></option>
<option value="AND">AND</option>
<option>AND NOT</option>
<option>OR</option>
</select>
</td>
<td class="last"></td>
</tr>
<tr id="ru1" class="siru">
<tr class="ruOp off">
<td class="first"></td>
<td colspan="3">
<td class="last"></td>
</tr>
<tr id="ru2" class="siru">
<tr class="groupBtm ruBorder" style="display: table-row;">
</tbody>
<tfoot>
</table>


我想选择AND选项

Selenium WebDriver代码

actions.moveToElement(driver.findElement(By.xpath("//*@id='ruTable']/tbody/tr[3]/td[2]"))).build().perform();
waitForElement(By.xpath("(//*[@id='ruTable']//*[contains(@class,'ruOpSelect')])[1]"),30);
new Select(driver.findElement(By.xpath("(//*[@id='ruTable']//*[contains(@class,'ruOpSelect')])[1]"))).selectByVisibleText("AND");


它会进行悬停操作,但不会从下拉菜单中选择任何内容


错误-等待By.xpath定位的元素的可见性在30秒后超时:
//*[@id='ruTable']//*[contains(@class,'ruOpSelect')])[1]

最佳答案

尝试使用此xpath,只需单击以下命令即可:

"//select[@class='ruOpSelect']/option[text()='AND']"


通常我在 select中以“ xpath”开头的任何下拉菜单都应该是下一个选项。

关于selenium - 从隐藏的下拉菜单中选择选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12097301/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com