use of org.openqa.selenium.Proxy in project saga by timurstrekalov.
the class GenericInstrumentingBrowser method getCapabilities.
private Capabilities getCapabilities() {
final String proxyUrl = "localhost:" + proxyServerPort;
final Proxy proxy = new Proxy().setProxyType(Proxy.ProxyType.MANUAL).setHttpProxy(proxyUrl).setSslProxy(proxyUrl);
final DesiredCapabilities desiredCapabilities = new DesiredCapabilities(config.getWebDriverCapabilities());
desiredCapabilities.setCapability(CapabilityType.PROXY, proxy);
desiredCapabilities.setJavascriptEnabled(true);
return desiredCapabilities;
}
use of org.openqa.selenium.Proxy in project ghostdriver by detro.
the class PhantomJSDriverService method createDefaultService.
/**
* Configures and returns a new {@link PhantomJSDriverService} using the default configuration.
*
* <br>
* In this configuration, the service will use the PhantomJS executable identified by the the
* following capability, system property or PATH environment variables:
* <ul>
* <li>{@link PhantomJSDriverService#PHANTOMJS_EXECUTABLE_PATH_PROPERTY}</li>
* <li>
* {@link PhantomJSDriverService#PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY}
* (Optional - without will use GhostDriver internal to PhantomJS)
* </li>
* </ul>
* <br>
* Each service created by this method will be configured to find and use a free port on the current system.
* <br>
* @param desiredCapabilities desired capabilities
*
* @return A new ChromeDriverService using the default configuration.
*/
public static PhantomJSDriverService createDefaultService(Capabilities desiredCapabilities) {
// Look for Proxy configuration within the Capabilities
Proxy proxy = null;
if (desiredCapabilities != null) {
proxy = Proxy.extractFrom(desiredCapabilities);
}
// Find PhantomJS executable
File phantomjsfile = findPhantomJS(desiredCapabilities, PHANTOMJS_DOC_LINK, PHANTOMJS_DOWNLOAD_LINK);
// Find GhostDriver main JavaScript file
File ghostDriverfile = findGhostDriver(desiredCapabilities, GHOSTDRIVER_DOC_LINK, GHOSTDRIVER_DOWNLOAD_LINK);
// Build & return service
return new Builder().usingPhantomJSExecutable(phantomjsfile).usingGhostDriver(ghostDriverfile).usingAnyFreePort().withProxy(proxy).withLogFile(findLogFile()).withAcceptSslCerts(findAcceptSslCerts(desiredCapabilities)).usingCommandLineArguments(findCLIArgumentsFromCaps(desiredCapabilities, PHANTOMJS_CLI_ARGS)).usingGhostDriverCommandLineArguments(findCLIArgumentsFromCaps(desiredCapabilities, PHANTOMJS_GHOSTDRIVER_CLI_ARGS)).build();
}
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.setConnectTimeout(90, TimeUnit.SECONDS);
server.setMitmDisabled(!Boolean.parseBoolean(Configuration.useMITM()));
server.setRequestTimeout(90, TimeUnit.SECONDS);
server.enableHarCaptureTypes(CaptureType.REQUEST_HEADERS, CaptureType.RESPONSE_HEADERS);
server.setUseEcc(true);
proxyServer = server.startBrowserMobProxyServer();
}
caps.setCapability(CapabilityType.PROXY, proxyServer);
}
}
Aggregations