use of org.openqa.selenium.Proxy in project selenium-tests by Wikia.
the class BrowserAbstract method setProxy.
/**
* Set Proxy instance for a Browser instance
*/
protected void setProxy() {
if (Configuration.useProxy()) {
Proxy proxyServer = new Proxy();
if ("true".equals(Configuration.useZap())) {
String zapProxyAddress = String.format("%s:%s", XMLReader.getValue("zap_proxy.address"), Integer.parseInt(XMLReader.getValue("zap_proxy.port")));
proxyServer.setHttpProxy(zapProxyAddress);
proxyServer.setSslProxy(zapProxyAddress);
} else {
server = new NetworkTrafficInterceptor();
server.setTrustAllServers(true);
server.setMitmDisabled(!Boolean.parseBoolean(Configuration.useMITM()));
server.setRequestTimeout(90, TimeUnit.SECONDS);
server.enableHarCaptureTypes(CaptureType.REQUEST_HEADERS, CaptureType.REQUEST_COOKIES, CaptureType.RESPONSE_HEADERS, CaptureType.RESPONSE_COOKIES);
proxyServer = server.startBrowserMobProxyServer();
}
caps.setCapability(CapabilityType.PROXY, proxyServer);
}
}
use of org.openqa.selenium.Proxy in project fess by codelibs.
the class WebDriverGenerator method createDriverService.
@SuppressWarnings("deprecation")
protected PhantomJSDriverService createDriverService(final Capabilities desiredCapabilities) {
// Look for Proxy configuration within the Capabilities
Proxy proxy = null;
if (desiredCapabilities != null) {
proxy = Proxies.extractProxy(desiredCapabilities);
}
// Find PhantomJS executable
String phantomjspath = null;
if (desiredCapabilities != null && desiredCapabilities.getCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY) != null) {
phantomjspath = (String) desiredCapabilities.getCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY);
} else {
phantomjspath = CommandLine.find(PHANTOMJS_DEFAULT_EXECUTABLE);
phantomjspath = System.getProperty(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, phantomjspath);
}
final File phantomjsfile = new File(phantomjspath);
// Build & return service
return //
new Builder().usingPhantomJSExecutable(phantomjsfile).usingAnyFreePort().withProxy(//
proxy).withLogFile(//
new File(ComponentUtil.getSystemHelper().getLogFilePath(), "phantomjs.log")).usingCommandLineArguments(//
findCLIArgumentsFromCaps(desiredCapabilities, PhantomJSDriverService.PHANTOMJS_CLI_ARGS)).build();
}
Aggregations