selenium with python:如何单击网页上某种类型的所有按钮
我正在尝试单击网页上某种类型的所有按钮,并从生成的弹出框中删除信息。到目前为止,我编写的代码在前4个按钮上都可以使用,下一步我会收到以下错误消息:
element notintactableException:消息:元素不相互作用
是我到目前为止写的代码:
driver = webdriver.Chrome()
url = 'https://www.handyverkauf.net/macbook-verkaufen/macbook-pro'
time.sleep(3)
driver.get(url)
time.sleep(3)
buttons = driver.find_elements_by_xpath("//a[@class='uk-button uk-button-small uk-button-primary']//span[@class='uk-hidden-small'][contains(text(),'Zum Vergleich')]")
buttons[4].click()
网页是: https://www.handyverkauf.net/macbook-verkaufen/macbook-pro
我已经附加了一个 ScreenShot 在这里显示我想单击的按钮。第一个4“ zum vergleich”工作正常(对于MacBook Pro 2021),但第五(MacBook Pro 2020)停止工作。
I am trying to click through all buttons of a certain type on a webpage and scrape the info from the resulting pop up boxes. The code I wrote so far works on the first 4 buttons and on the next I get the following error message:
ElementNotInteractableException: Message: element not interactable
Here is the code I wrote so far:
driver = webdriver.Chrome()
url = 'https://www.handyverkauf.net/macbook-verkaufen/macbook-pro'
time.sleep(3)
driver.get(url)
time.sleep(3)
buttons = driver.find_elements_by_xpath("//a[@class='uk-button uk-button-small uk-button-primary']//span[@class='uk-hidden-small'][contains(text(),'Zum Vergleich')]")
buttons[4].click()
The webpage is this: https://www.handyverkauf.net/macbook-verkaufen/macbook-pro
I have attached a
screenshot here which shows the buttons I would like to click. The first 4 'Zum Vergleich' work fine (for the MacBook Pro 2021) but then the fifth (for the Macbook pro 2020) stops working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论