Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x NoTouchElementException:无法选择下拉项_Python 3.x_Selenium_Automation_Scripting - Fatal编程技术网

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">&nbsp;Create Account&nbsp;&nbsp;<img src="../../images/actionitems_collapse.gif"></a>&nbsp;
    </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()