我正在使用 selenium 浏览此页面:
https://webapps.cityofchicago.org/activegcWeb/
但是我找不到如何移动到任何页面,使用 chrome 我得到了“下一个”按钮的 Xpath:
'//*[@id="id2"]/a[3]'
我正在使用此代码:
url = 'https://webapps.cityofchicago.org/activegcWeb/'
driver_1 = webdriver.Firefox()
driver_1.get(url)
content = driver_1.page_source
next_button_xpath = '//*[@id="id2"]/a[3]'
button = driver_1.find_element_by_xpath(next_button_xpath)
button.click()
但是我收到了这个错误:
'selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"//*[@id=\"id2\"]/a[3]"}'
最佳答案
使用 XPath 定位器“//a[contains(@href, 'headerPaginator:next')]”,然后单击。
关于python - 在 webapps 中查找按钮的 Xpath [Selenium],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36141442/