无法使用 Selenium 找到按钮 Python
Can't find button using Selenium Python
我是 Selenium 的新手,正在尝试单击 google 上的“使用权限”按钮,但是所有 5 个按钮的 html 代码似乎都相同(包括 class 姓名).
Screenshot of the html code and the usage rights button I'm referring to
我什至尝试使用链接文本来查找按钮:
driver.find_element_by_link_text("Usage Rights")
您可以使用这个 XPath 定位器:
driver.find_element_by_xpath("//div[@class='xFo9P r9PaP' and contains(text(),'Usage Rights')]")
不要忘记在此行之前放置 wait / delay 以让页面加载
我是 Selenium 的新手,正在尝试单击 google 上的“使用权限”按钮,但是所有 5 个按钮的 html 代码似乎都相同(包括 class 姓名).
Screenshot of the html code and the usage rights button I'm referring to
我什至尝试使用链接文本来查找按钮:
driver.find_element_by_link_text("Usage Rights")
您可以使用这个 XPath 定位器:
driver.find_element_by_xpath("//div[@class='xFo9P r9PaP' and contains(text(),'Usage Rights')]")
不要忘记在此行之前放置 wait / delay 以让页面加载