【发布时间】:2019-02-08 21:39:47
【问题描述】:
我正在尝试遍历用于网页抓取的下拉列表,但我注意到我的代码无法正常工作
dropdown = browser.find_element_by_XPATH('//*[@id="department-dropdown"]')
select = Select(dropdown)
select.select_by_value("Accounting")
我收到的错误消息
Traceback (most recent call last):
File "C:\Users\David\eclipse-workspace\Web_Scrap\setup.py", line 31, in <module>
dropdown = browser.find_element_by_XPATH('//*[@id="mainContent"]/div[1]/div/div[3]/div/div/span')
AttributeError: 'WebDriver' object has no attribute 'find_element_by_XPATH'
现在我试图选择至少第一个值,但它只是不工作
The picture provided has the "inspect element" of the dropdown box i'm attempting to cycle through
下拉框元素不是实际列表的一部分,这似乎有点令人困惑,有人可以告诉我这里实际发生了什么吗?如果我看错了。
如果有人对我可以做些什么来实现我的目标有任何建议
【问题讨论】:
-
find_element_by_XPATH应该是find_element_by_xpath
标签: python-3.x selenium selenium-webdriver xpath dropdown