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:in
create_capabilities' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.20.0/lib/s elenium/webdriver/chrome/bridge.rb:20:in
initialize' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.20.0/lib/s elenium/webdriver/common/driver.rb:37:innew' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.20.0/lib/s elenium/webdriver/common/driver.rb:37:in
for' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.20.0/lib/s elenium/webdriver.rb:61:infor' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.5.3/lib/watir -webdriver/browser.rb:35:in
initialize' 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:
browser = Watir::Browser.new :chrome, :switches => ['--proxy-server=88.12.44.205:3128']
Or if you have a lot of options to set, then you might do:
switches = Array.new
switches << '--proxy-server=88.12.44.205:3128'
#Add other switches values to the array
browser = Watir::Browser.new :chrome, :switches => switches
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With