Python,Selenium | Can';t单击此处测试

Python,Selenium | Can';t单击此处测试,python,python-3.x,selenium,google-chrome,selenium-chromedriver,Python,Python 3.x,Selenium,Google Chrome,Selenium Chromedriver,您好,我正在尝试通过chrome在Python中使用selenium单击“Test Here”按钮。我不知道什么东西坏了。我的代码在下面共享 驱动程序。通过xpath(“/*[contains(text(),'Test Here')]”查找\u元素。单击()您可以尝试以下方法: driver.find_element_by_link_text("Test Here").click() 单击按钮,而不是跨度 Add/parent::button将修复您的xpath。这是我得到

您好,我正在尝试通过chrome在Python中使用selenium单击“Test Here”按钮。我不知道什么东西坏了。我的代码在下面共享

驱动程序。通过xpath(“/*[contains(text(),'Test Here')]”查找\u元素。单击()

您可以尝试以下方法:

driver.find_element_by_link_text("Test Here").click()

单击按钮,而不是跨度


Add/parent::button将修复您的xpath。

这是我得到的错误…:(selenium.common.exceptions.NoSuchElementException:Message:没有这样的元素:无法定位元素:{“方法”:“链接文本”,“选择器”:“在这里测试”}(会话信息:chrome=88.0.4324.150)@ghost尝试添加行
“驱动程序。隐式地在
驱动程序之前等待(5)”
。通过链接文本(“在这里测试”)查找元素。单击()“
line.很抱歉,我对使用selenium很陌生。你能给我一个确切的例子吗?哦,复制它并把它放在xpath的末尾。它向上移动1级到按钮标记。//span[.='Test Here']/parent::button如上所述。