簡體   English   中英

如何在 Watir 中阻止圖像?

[英]How to block images in Watir?

我正在使用Watir進行數據獲取工作,我不需要加載任何圖像。 有沒有可能阻止他們?

我認為可以是:

        profile = Selenium::WebDriver::Chrome::Profile.new
        profile['webkit.webprefs.loads_images_automatically'] = false

        @browser = Watir::Browser.new :chrome, :profile => profile

見: http : //watir.github.io/docs/chrome/

用 :

webkit: { webprefs: { loads_images_automatically: false } } or profile: { default_content_setting_values: { images: 2 } }
prefs = {
    :profile => {
        :managed_default_content_settings => { 
          :images => 2
        }
    }
}

b = Watir::Browser.new :chrome, :prefs => prefs

手動禁用在瀏覽器 Watir 驅動器中顯示圖像,然后運行 ​​Watir 腳本。 據我所知,你不能從 Watir 本身做到這一點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM