Search in sources :

Example 26 with Proxy

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;
}
Also used : Proxy(org.openqa.selenium.Proxy) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities)

Example 27 with Proxy

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

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

Aggregations

Proxy (org.openqa.selenium.Proxy)28 Test (org.junit.Test)11 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)6 BrowserMobProxy (net.lightbody.bmp.BrowserMobProxy)4 File (java.io.File)3 BrowserMobProxyServer (net.lightbody.bmp.BrowserMobProxyServer)3 ProxyHostPort (com.googlecode.jmeter.plugins.webdriver.proxy.ProxyHostPort)2 SystemProxy (com.qaprosoft.carina.proxy.SystemProxy)2 UnsupportedBrowserException (ru.sbtqa.tag.pagefactory.exceptions.UnsupportedBrowserException)2 TestSetup (com.coveros.selenified.utilities.TestSetup)1 BrowserVersion (com.gargoylesoftware.htmlunit.BrowserVersion)1 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 Application (com.github.noraui.application.Application)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 BrowserMobProxySupplier (com.hribol.automation.core.suppliers.BrowserMobProxySupplier)1 DesiredCapabilitiesSupplier (com.hribol.automation.core.suppliers.DesiredCapabilitiesSupplier)1 SeleniumProxySupplier (com.hribol.automation.core.suppliers.SeleniumProxySupplier)1 NetworkTrafficInterceptor (com.wikia.webdriver.common.core.networktrafficinterceptor.NetworkTrafficInterceptor)1