有沒有辦法使用紅寶石禁用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