简体   繁体   中英

Using Selenium, enable “Pop-ups and redirects” in Chrome

Is there a way to enable "Pop-ups and redirects" in Chrome using Selenium? Am I using the ' disable-popup-blocking ' argument incorrectly?

chrome_options = Options()
chrome_options.add_argument("--disable-popup-blocking")
capabilities = {'chromeOptions':{'useAutomationExtension':False}}
chrome_options.binary_location = 'C:\\Program Files (x86)\\Google\\Chrome\\Application' 

When I start Chrome using code above, the setting is still on. Thank you.

I believe you're using incorrect setting, at least I fail to see anything like --disable-popup-blocking at Capabilities & ChromeOptions page.

My expectation is that you should amend your code to look like:

chrome_options = Options()
prefs = {"profile.default_content_settings.popups": 1}
chrome_options.add_experimental_option("prefs",prefs)
capabilities = {'chromeOptions':{'useAutomationExtension':False}}
chrome_options.binary_location = 'C:\\Program Files (x86)\\Google\\Chrome\\Application'

More information:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM