Reputation: 1503
I love watir webdriver and want to use it :)
Also love webdriver-user-agent
and browsermob-proxy
the thing is just started with ruby and Im confused about running those three together hier is the code:
require 'watir-webdriver'
require 'webdriver-user-agent'
require 'browsermob/proxy'
server = BrowserMob::Proxy::Server.new("/home/ubuntu/ruby/browsermob-proxy")
server.start
proxy = server.create_proxy
browser = Watir::Browser.new Webdriver::UserAgent.driver(:browser => :chrome, :agent => :iphone, :orientation => :landscape)
browser.goto 'google.com'
so how can I integrate proxy to the browser?
Upvotes: 2
Views: 1059
Reputation: 894
Something on these lines should work:
driver = Webdriver::UserAgent.driver(:browser => :chrome, :agent => :iphone, :orientation => :landscape)
browser = Watir::Browser.new driver, :switches => %w[--proxy-server=#{proxy.host}:#{proxy.port}]
browser.goto 'google.com'
Since you have already created the proxy, it's host and port values will be available (browsermob might not create the proxy on default port 8080, so I would advice to pick it from the proxy object itself).
Upvotes: 1
Reputation: 6075
if the server port is 8080 then you would do something like this
profile = Selenium::WebDriver::Firefox::Profile.new
profile.proxy = Selenium::WebDriver::Proxy.new :http => 'localhost:8080:, :ssl => 'localhost:8080'
b = Watir::Browser.new :chrome, :profile => profile
Upvotes: 1