Search in sources :

Example 6 with Proxy

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);
    }
}
Also used : Proxy(org.openqa.selenium.Proxy) NetworkTrafficInterceptor(com.wikia.webdriver.common.core.networktrafficinterceptor.NetworkTrafficInterceptor)

Example 7 with Proxy

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();
}
Also used : Proxy(org.openqa.selenium.Proxy) Builder(org.openqa.selenium.phantomjs.PhantomJSDriverService.Builder) File(java.io.File)

Aggregations

Proxy (org.openqa.selenium.Proxy)7 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)3 File (java.io.File)2 BrowserMobProxy (net.lightbody.bmp.BrowserMobProxy)2 BrowserMobProxyServer (net.lightbody.bmp.BrowserMobProxyServer)2 BrowserVersion (com.gargoylesoftware.htmlunit.BrowserVersion)1 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 FileServer (com.github.timurstrekalov.saga.core.FileServer)1 InstanceFieldPerPropertyConfig (com.github.timurstrekalov.saga.core.cfg.InstanceFieldPerPropertyConfig)1 InstrumentingProxyServer (com.github.timurstrekalov.saga.core.server.InstrumentingProxyServer)1 NetworkTrafficInterceptor (com.wikia.webdriver.common.core.networktrafficinterceptor.NetworkTrafficInterceptor)1 HttpResponse (io.netty.handler.codec.http.HttpResponse)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 ResponseFilter (net.lightbody.bmp.filters.ResponseFilter)1 HttpMessageContents (net.lightbody.bmp.util.HttpMessageContents)1 HttpMessageInfo (net.lightbody.bmp.util.HttpMessageInfo)1 Before (org.junit.Before)1