我试图在一个页面上点击多个下拉列表,但是我一直收到一个错误消息,说我的列表对象没有属性标记“name”。在
我的代码
def click_follow_buttons(driver):
selects = Select(driver.find_elements_by_class_name("jBa"))#jBa
print selects
for select in selects:
select.select_by_index(0)
driver.find_element_by_class_name("bA").click()
我的回溯
^{pr2}$Html下拉列表
^{3}$
首先,您使用的是
find_elements_by_class_name()
方法,它将返回一个匹配类名而不是单个元素的web元素列表。在但是,即使使用
find_element_by_class_name()
,也会得到不同的错误,因为这是一个与类名匹配的div
元素,而不是select
元素。在您需要传递给
Select
类web元素的构造函数,该元素具有select
标记名: https://selenium.googlecode.com/git/docs/api/py/webdriver_support/selenium.webdriver.support.select.html相关问题 更多 >
编程相关推荐