- Watir Tutorial
- Watir - Home
- Watir - Overview
- Watir - Introduction
- Watir - Environment Setup
- Watir - Installing Drivers for Browsers
- Watir - Working with Browsers
- Watir - Web Elements
- Watir - Locating Web Elements
- Watir - Working with Iframes
- Watir - Automatic Waits
- Watir - Headless Testing
- Watir - Mobile Testing
- Watir - Capturing Screenshots
- Watir - Page Objects
- Watir - Page Performance
- Watir - Cookies
- Watir - Proxies
- Watir - Alerts
- Watir - Downloads
- Watir - Browser Windows
- Watir Useful Resources
- Watir - Quick Guide
- Watir - Useful Resources
- Watir - Discussion
Watir - Proxies
Watir allows to use proxy with the help of proxy object which needs to be used with the browser.
Syntax
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 −
Example
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 −
Example
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 −
Advertisements
To Continue Learning Please Login
Login with Google