gpt4 book ai didi

python - 无法使用selenium单击div按钮

转载 作者:行者123 更新时间:2023-11-30 22:10:21 25 4
gpt4 key购买 nike

我想单击一个实际上是 div 标签的按钮。我无法点击它。

from selenium import webdriver

url = "https://www.qoo10.sg/item/LAPTOP-SCREEN-PROTECTOR-SCREEN-GUARD-FOR-13-14-15-INCHES-2ND/410235318"

driver = webdriver.Firefox()
driver.get(url)

elem = driver.find_element_by_class_name('selectArea').click()

当我运行这个程序时,出现这个错误

selenium.common.exceptions.ElementNotInteractableException: Message: Element <div id="ship_to_outer" class="selectArea"> could not be scrolled into view.

最佳答案

有 4 个按钮具有相同的类名“ship_to_outer” - 第一个按钮是隐藏的,因此您无法单击它。请尝试下面的代码

driver.find_element_by_xpath('//div[@class="selectArea" and not(@id="ship_to_outer")]').click()

关于python - 无法使用selenium单击div按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51700886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com