質問

I'm trying crawl along some pages with watir-webdriver and chromium. I haven't got any success by googling arround so here is my question:

I don't need any images so, to speed up things, I try to disable image loading.

Using firefox as my browser is relatively straigtforward

profile = Selenium::WebDriver::Firefox::Profile.new
profile['network.image.imageBehavior'] = 2
browser = Watir::Browser.new :firefox, :profile => profile

But I haven't had any success with chromium. As far as I've learned, you can set preferences and pass commandline options this way (an example):

prefs = {
    :download => {
        :prompt_for_download => false,
        :default_directory => '/tmp'
    },
}
args = ['--start-maximized', '--incognito']
browser = Watir::Browser.new :chrome, :prefs => prefs, :args => args,

That works ok. The problem is that, AFAIK, there are no commandline options nor preferences to block images in chromium.

Any idea?

My setup:

  • LinuxMint 16 (32.0.1700.107-0ubuntu0.13.10.1~20140204.972.1)
  • ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
  • watir-webdriver v0.6.8
  • chromedriver v2.9.248304
  • chromium-browser 32.0.1700.107 Built on Ubuntu 13.10
役に立ちましたか?

解決

I've managed to disable image loading and many more things through a proxy, being any the choosen browser driver.

I used a local proxy called privoxy in my case.

他のヒント

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

b = Watir::Browser.new :chrome, :prefs => prefs
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top