有没有办法使用红宝石禁用Chromedriver中的图像?有一个类似的问题,但它涉及C#,我不确定如何将它移植到ruby。ChromeDriver Ruby禁用图像
Disable images in Selenium ChromeDriver
有没有办法使用红宝石禁用Chromedriver中的图像?有一个类似的问题,但它涉及C#,我不确定如何将它移植到ruby。ChromeDriver Ruby禁用图像
Disable images in Selenium ChromeDriver
看起来它需要一个散列发送到“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)
自从@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)
对于任何人谁遇到这一点,并使用镀铬无头,这里是如何禁用图像。
options = Selenium::WebDriver::Chrome::Options.new(args: ['headless', '--blink-settings=imagesEnabled=false'])
@driver = Selenium::WebDriver.for(:chrome, options: options)
嗨,bbbco。我尝试了这个答案,但它没有奏效。我正在使用'水豚(2.10.1)'和 – timlentse 2016-10-28 09:15:38