I’m trying to access web from watir webdriver through proxy. Can be HTTP or SOCKS
Here is my code so far. I found sample (last 3 lines), but it gives me error:
irb
require "watir-webdriver"
browser = Watir::Browser.new :chrome
switches = '--proxy-server=88.12.44.205:3128'
browser = Watir::Browser.new :chrome, :switches => switches
browser.goto "http://ipaddresslocation.org"
Started ChromeDriver port=53928 version=18.0.1022.0
log=C:\Users\Raimis\chromedriver.log ArgumentError: :args must be an
Array of Strings
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.20.0/lib/s
elenium/webdriver/chrome/bridge.rb:71:increate_capabilities'initialize’
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.20.0/lib/s
elenium/webdriver/chrome/bridge.rb:20:in
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.20.0/lib/s
elenium/webdriver/common/driver.rb:37:innew'for’
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.20.0/lib/s
elenium/webdriver/common/driver.rb:37:in
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.20.0/lib/s
elenium/webdriver.rb:61:infor'initialize’
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.5.3/lib/watir
-webdriver/browser.rb:35:in
from (irb):6:innew'‘
from (irb):6
from C:/Ruby193/bin/irb:12:in
this line gives me error
browser = Watir::Browser.new :chrome, :switches => switches
Any tips on how solve this error?
Edit:
here is the final code which worked for me:
irb
require "watir-webdriver"
browser = Watir::Browser.new :chrome, :switches => ['--proxy-server=88.12.44.205:3128']
browser.goto "http://ipaddresslocation.org"
The problem is that the ‘switches’ value needs to be an ‘array of strings’ rather than just a string.
The following should work:
Or if you have a lot of options to set, then you might do: