Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法单击“";“关闭”;按钮 接近 浏览器。通过链接文本(“关闭”)查找元素。单击()_Python_Selenium_Selenium Webdriver_Webdriver - Fatal编程技术网

Python 无法单击“";“关闭”;按钮 接近 浏览器。通过链接文本(“关闭”)查找元素。单击()

Python 无法单击“";“关闭”;按钮 接近 浏览器。通过链接文本(“关闭”)查找元素。单击(),python,selenium,selenium-webdriver,webdriver,Python,Selenium,Selenium Webdriver,Webdriver,这个按钮是什么 您的“关闭”按钮不是一个链接,而是一个,因此不要使用通过链接文本查找元素 你有什么例外?我假设您有一个“NoTouchElementException”,那么在没有看到更多HTML的情况下,我无法为您提供最好的定位器,因为您可能有更多带有文本Close、凌乱的空格或具有相同类名的许多其他跨度ui按钮 但请尝试以下方法(假设您只有一个关闭按钮,没有混乱的空白): 编辑:考虑到网站的安全性,问题是你有更多的“关闭”按钮,这些按钮是不可见的,因此你需要更好的XPath browser.

这个按钮是什么

您的“关闭”按钮不是一个链接,而是一个
,因此不要使用
通过链接文本查找元素

你有什么例外?我假设您有一个“NoTouchElementException”,那么在没有看到更多HTML的情况下,我无法为您提供最好的定位器,因为您可能有更多带有文本
Close
、凌乱的空格或具有相同类名的许多其他跨度
ui按钮

但请尝试以下方法(假设您只有一个关闭按钮,没有混乱的空白):

编辑:考虑到网站的安全性,问题是你有更多的“关闭”按钮,这些按钮是不可见的,因此你需要更好的XPath

browser.find_element_by_xpath(".//span[text()='Close']").click()

ElementNotVisibleException虽然我申请了10秒sleep@neha当前位置正如我所说,我假设您有一个关闭按钮,但看起来您没有更多按钮。请尝试将XPath更改为
/*[@id='notificationArea']/../..//span[text()='Close']
browser.find_element_by_xpath(".//span[text()='Close']").click()
browser.find_element_by_xpath(".//*[@id='notificationArea']/..//span[text()='Close']").click()