I am using Selenium with PhantomJS browser. I have set up proxy as below:
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setJavascriptEnabled(true);
System.setProperty("phantomjs.binary.path", "../Drivers/phantomjs.exe");
ArrayList<String> cliArgsCap = new ArrayList<String>();
cliArgsCap.add("--proxy=hostname:port");
cliArgsCap.add("--proxy-auth=username:password");
cliArgsCap.add("--proxy-type=http");
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
driver = new PhantomJSDriver(capabilities);
My application is running fine. But how to validate if my application is using the proxy that I have set up?
Before running your main script, make request to http://api.ipify.org/ that shows client's current IP and check in the code if it's your IP or the proxy IP.