【发布时间】:2021-11-13 02:06:26
【问题描述】:
我需要你的帮助。我正在使用 selenium 单击网页上的按钮,然后打开其他选项。不幸的是,它无法识别 Path 元素。网络模拟器是移动版,因为它更容易访问按钮(问题与桌面版相同)。我尝试点击网页上的其他按钮,它工作正常。
mobile_emulation = { "deviceName": "Galaxy S5" }
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
driver = webdriver.Chrome(chromedriver_path, options=chrome_options)
driver.get('https://www...')
time.sleep(20)
Click1 = driver.find_element_by_xpath('//*[@id="header_3"]/div')
Click1.click()
错误是:
NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="header_3"]/div"}
(Session info: chrome=93.0.4577.82)
网页代码图片如下:
感谢您的帮助!
【问题讨论】:
-
欢迎来到 Stack Overflow。请添加导入以提供最小的可重现示例。
标签: python selenium selenium-webdriver web-scraping selenium-chromedriver