如何使用Selenium在Chrome中禁用“某个网站想要打开此应用程序”的警告?

huangapple go评论112阅读模式
英文:

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?

如何使用Selenium在Chrome中禁用“某个网站想要打开此应用程序”的警告?

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.

huangapple
  • 本文由 发表于 2023年2月23日 23:29:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75546926.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定