【问题标题】:Selenium - disable popup blockerSelenium - 禁用弹出窗口拦截器
【发布时间】:2013-02-26 17:25:59
【问题描述】:

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

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

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

【问题讨论】:

  • 今天我也发生了同样的事情。关于这个问题的任何更新?

标签: safari selenium-webdriver selenium-grid popup-blocker


【解决方案1】:

好的,这是我最终编写的 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 等云服务。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-04
    • 2016-10-27
    • 1970-01-01
    • 2022-11-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多