2013-03-05 15 views

回答

0

看起來它需要一個散列發送到「profile.default_content_settings」 Chrome個人資料設置。我會嘗試這樣的事情:

profile = Selenium::WebDriver::Chrome::Profile.new 
profile["profile.default_content_settings"] = { :images => '2' } 

@driver = Selenium::WebDriver.for(:chrome, :profile => profile) 
+0

嗨,bbbco。我嘗試了這個答案,但它沒有奏效。我正在使用'水豚(2.10.1)'和 – timlentse 2016-10-28 09:15:38

0

自從@bbbco添加了他的答案後,要設置的標誌已經改變。正確的標誌是:"profile.managed_default_content_settings.images"使工作代碼:

profile = Selenium::WebDriver::Chrome::Profile.new 
profile["profile.managed_default_content_settings.images"] = 2 

@driver = Selenium::WebDriver.for(:chrome, :profile => profile) 
1

對於任何人誰遇到這一點,並使用鍍鉻無頭,這裏是如何禁用圖像。

options = Selenium::WebDriver::Chrome::Options.new(args: ['headless', '--blink-settings=imagesEnabled=false']) 
@driver = Selenium::WebDriver.for(:chrome, options: options)