单击Selenium中的X按钮
这是我目前正在查看的网站的链接:。滚动到页面底部,然后单击“查看更多”。
我正在尝试弄清楚如何单击X按钮,但是我尝试过的方法尚未奏效。我得到一个“没有这样的元素:无法找到元素错误。
我尝试了所有这三个:
driver.find_element(By.CLASS_NAME, "button").click()
driver.find_element_by_xpath("//button[contains(@data-testid='CloseIcon')]").click()
driver.find_element_by_tag_name("svg").click()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查
的XPATH加载更多
按钮//*[@ID =“ root”]/div [2]/div/div/div/div [2]/div [2]/div [3 ]/button
-
/I.SSTATIC.NET/SZ255.png“ rel =” nofollow noreferrer“>
x
按钮的完整XPath-'/html/html/hody/div [2]/div [3]/div/div/h2/button'
工作代码 -
Check the Xpath of the
load more
button//*[@id="root"]/div[2]/div/div[2]/div[2]/div[3]/button
-And then check the full Xpath of the
X
button that will close the pop-up windowfull Xpath of the
X
button -'/html/body/div[2]/div[3]/div/h2/button'
working code -