Watir allows to use proxy with the help of proxy object which needs to be used with the browser.
proxy = { http: '127.0.0.1:8080', ssl: '127.0.0.1:8080' } b = Watir::Browser.new :chrome, proxy: proxy
An example on how to use proxy with Chrome browser is shown below −
require "watir" proxy = { http: '127.0.0.1:8080', ssl: '127.0.0.1:8080' } b = Watir::Browser.new :chrome, proxy: proxy b.goto 'google.com' b.screenshot.save 'proxy.png'
We have used proxy object as shown below −
proxy = { http: '127.0.0.1:8080', ssl: '127.0.0.1:8080' }
The proxy address details are to be used for both http and ssl. We can use proxy with chrome browser as shown below −
b = Watir::Browser.new :chrome, proxy: proxy
The output proxy.png is shown below −
An example on how to use proxy with Firefox browser is discussed below −
require "watir" proxy = { http: '127.0.0.1:8080', ssl: '127.0.0.1:8080' } b = Watir::Browser.new :firefox, proxy: proxy b.goto 'google.com' b.screenshot.save 'proxyfirefox.png'
You can add the proxy details as shown below −
proxy = { http: '127.0.0.1:8080', ssl: '127.0.0.1:8080' } b = Watir::Browser.new :firefox, proxy: proxy
The output proxyfirefox.png is shown here −