gpt4 book ai didi

safari - Selenium - 禁用弹出窗口阻止程序

转载 作者:行者123 更新时间:2023-12-04 18:28:37 25 4
gpt4 key购买 nike

我刚刚花了几个小时在 SeleniumSafari 上停留,然后才发现我需要禁用弹出窗口阻止程序以允许我拥有的登录弹出窗口。

我的问题是,在使用 Selenium Grid 2 创建节点/webdriver 时,或者在代码中创建 RemoteWebDriver 时,有没有办法禁用弹出窗口阻止程序,或者两者都有?

否则,我必须手动记住通过自己打开浏览器来更改此设置。目的是让 Selenium 在多台机器上运行,因此能够以编程方式设置它会很棒。

最佳答案

好的,这是我最终编写的 AppleScript:

tell application "System Events" to tell process "Safari"
set frontmost to true
keystroke "," using {command down} -- open preferences
delay 1
tell window "Security"
tell group 1
tell group 1
click checkbox "Block pop-up windows"
end tell
end tell
key code 53 -- close preferences
end tell
end tell

如果您将它保存为popup.as,您可以像这样运行它:

$ osascript popup.as

请记住,这仅适用于本地,不适用于像 Sauce Labs 这样的云服务。

关于safari - Selenium - 禁用弹出窗口阻止程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15095389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com