Josh
Josh

Reputation: 51

How to test website with webdriver using different IPs

I am currently using the selenium webdriver and Java to test a website. There is a page on the site that displays information specific to your location, via IP address. I need to test the website for 4 different IP addresses. I'm looking to verify that this information is being displayed under the correct circumstances, using complete automation.

I was looking into solutions, and many people have suggested using a proxy, a VM, or selenium server. Would selenium server fit my needs? Is this possible without having to manually interact with the page itself?

Thanks for any help.

Upvotes: 0

Views: 2814

Answers (2)

Manu
Manu

Reputation: 2291

It's not exactly the Selenium Server that will solve your problem but Selenium Grid. Using Selenium Grid, you can run your tests on multiple machines and, hence, on different IP's.

Using VM's, you can ensure that your tests run on real browsers without manual interventions; it's more or less similar to using selenium grid.

I would suggest using proxy, as it will save you time needed to initialize hardware for your tests when you run on different machines, and you can run test easily just by setting the proxy in WebDriver profile. Documentation can be found here.

Upvotes: 0

Andrew
Andrew

Reputation: 11477

Use different proxies in your tests. But its pretty hard for most part of browsers, believe me. Easiest is to use phantomJS for use proxies in your tests:

// Proxy settings
string proxyHostStr = string.Format("{0}:{1}", proxyHost, proxyPort);
string proxyAuth = string.Format("{0}:{1}", proxyLogin, proxyPassword);

var serviceJs = PhantomJSDriverService.CreateDefaultService(phantomPath);
serviceJs.AddArguments("--proxy=" + proxyHostStr, "--proxy-type=http", "--proxy-auth=" + proxyAuth);

driver = new PhantomJSDriver(serviceJs);

Upvotes: 0

Related Questions