我想单击一个实际上是 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/