2013-03-05 76 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)