2013-02-26 61 views
3

我剛剛花了幾個小時卡在SeleniumSafari之後才發現我需要禁用彈出窗口阻止程序來允許我有一個登錄彈出窗口。硒 - 禁用彈出窗口阻止程序

我的問題是,有沒有辦法在創建節點/網絡驅動器時使用Selenium Grid 2或在代碼中創建RemoteWebDriver時禁用彈出窗口阻止程序?

否則,我必須手動記住通過自己打開瀏覽器來更改此設置。其目標是讓Selenium跨越多臺機器,因此能夠以編程方式進行設置將會很棒。

+0

今天同樣的事情發生在我身上。有關此問題的任何更新? – elaichi 2014-02-21 02:50:30

回答

0

好吧,這裏是我結束了寫作的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這樣的雲服務。

相關問題