【发布时间】:2020-10-28 19:43:51
【问题描述】:
我正在使用 python 3.7 并且在 selenium 中遇到错误
我有一个类似的网站:
<html>
<body>
<div class="foo">
<div class="bar1">something clickable</div>
<div class="bar2">something clickable</div>
<div class="bar3">something clickable</div>
<div class="bar4">something clickable</div>
</div>
<body>
<html>
我想使用 selenium 来点击每个条,所以我写道:
from selenium import webdriver
browser=webdriver.Chrome()
browser.get('https://www.some-website.com')
for i in browser.find_elements_by_class_name('foo'):
i.click()
但是,执行时我什么也没得到,所以我运行:
print(len(browser.find_elements_by_class_name('foo')))
输出为零
即使我在得到零之前输入WebDriverWait...
为什么?
【问题讨论】:
标签: python html python-3.x selenium selenium-webdriver