英文:
How to disable the "some site wants to open this application" alert in Chrome using Selenium?
问题
如何屏蔽这个弹出窗口?
options = webdriver.ChromeOptions()
options.add_argument("--disable-extensions")
options.add_argument('--disable-popup-blocking')
driver = webdriver.Chrome(options=options)
英文:
How to block this pop-up?
An English equivalent would be:
> This site is trying to open Spotify.
>
> https://open.spotify.com wants to open this application.
>
> □ Always allow open.spotify.com to open links of this type in the associated app
I tried to use:
options = webdriver.ChromeOptions()
options.add_argument("--disable-extensions")
options.add_argument('--disable-popup-blocking')
driver = webdriver.Chrome(options=options)
答案1
得分: 0
当运行Selenium webdriver时,Chrome会打开一个新的浏览会话,使用默认的Chrome配置文件(没有任何自定义设置)。
要解决这个问题,你可以通过使用--user-data-dir=/your/profile/data/location
参数来设置配置文件目录。在这个位置,Chrome将创建一个新的配置文件位置。当你的脚本运行时,手动导航到应该在屏幕上打开的Chrome窗口,并简单地启用始终打开选项。
下次你使用相同的配置文件目录运行你的脚本时,不应该再看到这个弹出窗口。
英文:
When running the Selenium webdriver, Chrome opens a new browsing session with the default Chrome profile (without any custom settings).
To get around this, you can set a profile directory by using the --user-data-dir=/your/profile/data/location
argument. In this location Chrome will create a new profile location. When your script is running, manually navigate to the Chrome window that should have opened on your screen and simply enable the always open option.
The next time you run your script using the same profile directory you shouldn't see this pop-up.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论