Webdriver Python禁用Safari浏览器推送通知

2024-05-12 17:15:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Python运行seleniumwebdriver,并尝试在Safari中禁用浏览器推送通知。我已经能够在我的Chrome和Firefox设置中做到这一点。你知道吗

在Firefox中,我使用以下代码禁用推送通知:

profile = webdriver.FirefoxProfile()
profile.set_preference("dom.webnotifications.enabled", False)

在Chrome中,我使用这个:

from selenium.webdriver.chrome.options import Options

opt = Options()
opt.add_argument("--disable-notifications")

在Safari中,我尝试使用setu权限禁用推送通知,但没有成功。你知道吗

driver = webdriver.Safari()
driver.set_permission("--disable-notifications", True)

Tags: 代码driver浏览器chromefirefoxprofilenotificationssafari