我正在使用Selenium和PhantomJS浏览器。我已经设置了如下代理:
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);
我的应用程序运行正常。但是如何验证我的应用程序是否正在使用我设置的代理?
答案 0 :(得分:0)
您可以在本地使用fiddler到setup a proxy server,然后将您的selenium代理配置更改为您已设置的代理。让我们运行你的应用程序,如果你的应用程序将抛出代理,那么fiddler将抓住它。
答案 1 :(得分:0)
在运行主脚本之前,请向显示客户当前IP的http://api.ipify.org/发出请求,并检查代码是否为您的IP或代理IP。