How to block images in Watir?

此生再无相见时 提交于 2019-12-07 11:55:25

问题


I am using Watir for a data fetching job where I don't need any images to be loaded. Is it possible to block them?


回答1:


Disable displaying images in the browser Watir drives manually, and then run Watir script. As far as I know, you can not do it from Watir itself.




回答2:


I think it can be:

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

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

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




回答3:


prefs = {
    :profile => {
        :managed_default_content_settings => { 
          :images => 2
        }
    }
}

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


来源:https://stackoverflow.com/questions/3386318/how-to-block-images-in-watir

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!