Python 3.x NoTouchElementException:无法选择下拉项
我无法选择下拉列表。 下拉列表的代码是Python 3.x NoTouchElementException:无法选择下拉项,python-3.x,selenium,automation,scripting,Python 3.x,Selenium,Automation,Scripting,我无法选择下拉列表。 下拉列表的代码是 <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr class="navigatorTable"> <td nowrap="" align="left"> <span class="dropdownbutton showSingle bound"> &
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr class="navigatorTable">
<td nowrap="" align="left">
<span class="dropdownbutton showSingle bound">
<a><img class="vAlignSub" src="/images/add.gif"> Create Account <img src="../../images/actionitems_collapse.gif"></a>
</span>
</td>
</tr>
</tbody>
</table>
但是我越来越
selenium.common.exceptions.NoSuchElementException: Message: no such element:
Unable to locate element: {"method":"xpath",
"selector":"//span[@class='dropdownbutton showSingle bound']"}
请帮我查一下密码。谢谢在本例中,您不能使用Select,因为类名表示它是下拉列表,但它不是Select html节点。所以,这里不能使用选择方法
您必须确保脚本等待span元素加载
#Imports required
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as E
现在获取元素并单击它检查xpath
ele = WebDriverWait(driver,30).until(EC.presence_of_element_located((By.XPATH,"//span[@class='dropdownbutton showSingle bound']//img")))
ele.click()
谢谢你,苏普图里。如果这个/任何答案对你有帮助,为了未来读者的利益,谢谢你的回答
ele = WebDriverWait(driver,30).until(EC.presence_of_element_located((By.XPATH,"//span[@class='dropdownbutton showSingle bound']//img")))
ele.click()