Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to block images in Watir?

Tags:

ruby

watir

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?

like image 593
Shubham Avatar asked Feb 27 '23 13:02

Shubham


2 Answers

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/

like image 54
mpz Avatar answered Mar 12 '23 00:03

mpz


Use :

webkit: { webprefs: { loads_images_automatically: false } } or profile: { default_content_setting_values: { images: 2 } }
like image 28
Astrit Shuli Avatar answered Mar 12 '23 00:03

Astrit Shuli