在 Selenium Python 中关闭浏览器弹出窗口 [英] Close browser popup in Selenium Python

查看:103
本文介绍了在 Selenium Python 中关闭浏览器弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Selenium、Python 抓取页面.打开页面时会出现一个弹出窗口.无论如何,我想关闭此弹出窗口.我试过如下:

I am scraping a page using Selenium, Python. On opening the page one Popup appears. I want to close this popup anyway. I tried as below:

url = https://shopping.rochebros.com/shop/categories/37

browser = webdriver.Chrome(executable_path=chromedriver, options=options)
browser.get(url)
browser.find_element_by_xpath("//button[@class='click' and @id='shopping-selector-parent-process-modal-close-click']").click()

我在这里尝试了几个类似的帖子,但没有任何效果.在错误下方,我得到了.

I tried a couple of similar posts here but nothing is working with me. below the error, I am getting.

 Message: no such element: Unable to locate element: {"method":"xpath","selector":"//button[@class='click' and @id='shopping-selector-parent-process-modal-close-click']"}

推荐答案

所需元素是 Modal Dialog 中的

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆