Selenium Testing on a Single IP in Firefox
Firefox, among other browsers, enables the recording, editing, and debugging of functional tests created in Selenium. These can be run as requests over a proxy server.
By default, a given request will use a random IP from the proxy; but to limit a request to a single IP, follow the steps described below.
Custom Headers
Use the X-ProxyMesh-IP
to specify a particular IP for the request. This IP should come from the X-ProxyMesh-IP
response header of a previous request.
OR
Use the X-ProxyMesh-Prefer-IP
header when you want to use a specific IP for a request, but you also want the request to succeed even if the IP is no longer available, in which case a random IP is chosen instead.
Authentication Header String
To control the IP addresses, you may also use a random string in the Proxy-Authorization header. Then, you pass in username:string:password
, where string
is a random string that you generate.
As long as you keep using the same string – assuming the outgoing IP is available – the proxy server will choose that same outgoing IP. If the IP is no longer available, then a new IP will be chosen by the proxy server, and will be used for subsequent requests with the same string.
Scripting Language Configurations
You may also wish to review configuration settings in ProxyMesh for specific scripting languages. Here are links to two examples:
- "Selenium + Firefox" in Python Proxy Configuration Examples
- "Selenium and Java with ProxyMesh" in Java Proxy Configuration Examples
Version Interactions
Selenium and Firefox interact differently, depending on the respective versions used. The web article Selenium (software) covers these varying interactions.
Selenium WebDriver
You may wish to look into the WebDriver feature included in Selenium as of version 2.0. The WebDriver API provides a platform- and language-neutral wire protocol.
This enables users to write instruction sets to run interchangeably in many browsers on different platforms. You can create tests in most scripting languages commonly used for ProxyMesh requests.