【发布时间】:2019-01-14 08:51:55
【问题描述】:
我正在尝试创建一个脚本,该脚本可以自动单击下拉框并单击我想要的选项。我已经尝试实现另一个类似问题的代码,但是我收到了一条错误消息。
使用类似问题的解决方案,我尝试了这行代码:
driver.find_element_by_xpath("//select[@name='interface']/option[text()='Management']").click()
HTML
<select class="col-1 custom-select" name="interface" id="interface" required="required">
<option selected="" disabled="" class="hideoption">Select Interface</option>
<option value="InterfaceLAN">Production</option>
<option value="MgmtLAN">Management</option>
<option value="Clustering">Clustering</option>
</select>
我想自动执行单击下拉框并选择“管理”选项的过程。但是,我收到一条错误消息,如图所示:
NoSuchElementException: Message: no such element: Unable to locate element:"method":"xpath","selector":"//select[@name='interface']/option[text()='Management']"}
【问题讨论】:
-
@Andersson 现在你决定删除你对这个问题的回答,强行关闭这个讨论作为一个重复是完全不道德的。这是一个明显滥用提供给您的特权,因为重复是一个金牌 i> 带有
selenium标签的支架。 -
@DebanjanB 发布重复的答案不是完全不道德吗?
标签: python selenium selenium-webdriver xpath webdriverwait