Search in sources :

Example 11 with Proxy

use of org.openqa.selenium.Proxy in project jmeter-plugins by undera.

the class ProxyFactoryTest method shouldCreateDirectProxy.

@Test
public void shouldCreateDirectProxy() {
    Proxy proxy = factory.getDirectProxy();
    assertThat(proxy.getProxyType(), is(Proxy.ProxyType.DIRECT));
}
Also used : Proxy(org.openqa.selenium.Proxy) Test(org.junit.Test)

Example 12 with Proxy

use of org.openqa.selenium.Proxy in project selenium_java by sergueik.

the class RecordSettingsBase method prepareRecord.

@Override
public void prepareRecord(int timeout) {
    this.proxy = new BrowserMobProxySupplier(timeout, requestFilter, responseFilter).get();
    Proxy seleniumProxy = new SeleniumProxySupplier(proxy).get();
    DesiredCapabilities desiredCapabilities = new DesiredCapabilitiesSupplier(seleniumProxy).get();
    this.driver = webDriverSupplier.get(desiredCapabilities);
    this.driver.manage().window().maximize();
}
Also used : DesiredCapabilitiesSupplier(com.hribol.automation.core.suppliers.DesiredCapabilitiesSupplier) Proxy(org.openqa.selenium.Proxy) BrowserMobProxy(net.lightbody.bmp.BrowserMobProxy) SeleniumProxySupplier(com.hribol.automation.core.suppliers.SeleniumProxySupplier) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) BrowserMobProxySupplier(com.hribol.automation.core.suppliers.BrowserMobProxySupplier)

Example 13 with Proxy

use of org.openqa.selenium.Proxy in project Asqatasun by Asqatasun.

the class ProfileFactory method setUpProxy.

private void setUpProxy(FirefoxProfile firefoxProfile) {
    if (!StringUtils.isEmpty(proxyPort) && !StringUtils.isEmpty(proxyHost)) {
        StringBuilder strb = new StringBuilder(proxyHost);
        strb.append(":");
        strb.append(proxyPort);
        Proxy proxy = new Proxy();
        proxy.setFtpProxy(strb.toString());
        proxy.setHttpProxy(strb.toString());
        proxy.setSslProxy(strb.toString());
        if (StringUtils.isNotEmpty(proxyExclusionUrl)) {
            proxy.setNoProxy(proxyExclusionUrl.replaceAll(";", ","));
        }
        firefoxProfile.setProxyPreferences(proxy);
    }
}
Also used : Proxy(org.openqa.selenium.Proxy)

Example 14 with Proxy

use of org.openqa.selenium.Proxy in project opennms by OpenNMS.

the class DatabaseReportIT method customizeCapabilities.

// setup proxy and response filter
@Override
protected void customizeCapabilities(DesiredCapabilities caps) {
    proxy = new BrowserMobProxyServer();
    proxy.start(0);
    proxy.addResponseFilter(new ResponseFilter() {

        @Override
        public void filterResponse(HttpResponse response, HttpMessageContents contents, HttpMessageInfo messageInfo) {
            if (isReportDownloadResponse(response)) {
                LOG.info("Report download response received with headers: {}", response.headers().entries());
                try (ByteArrayInputStream input = new ByteArrayInputStream(contents.getBinaryContents());
                    FileOutputStream output = new FileOutputStream(getFile())) {
                    ByteStreams.copy(input, output);
                } catch (IOException e) {
                    Throwables.propagate(e);
                }
            }
        }
    });
    // configure the Browser Mob Proxy as a desired capability
    Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
    caps.setCapability(CapabilityType.PROXY, seleniumProxy);
}
Also used : Proxy(org.openqa.selenium.Proxy) BrowserMobProxy(net.lightbody.bmp.BrowserMobProxy) ByteArrayInputStream(java.io.ByteArrayInputStream) FileOutputStream(java.io.FileOutputStream) ResponseFilter(net.lightbody.bmp.filters.ResponseFilter) HttpResponse(io.netty.handler.codec.http.HttpResponse) HttpMessageInfo(net.lightbody.bmp.util.HttpMessageInfo) IOException(java.io.IOException) BrowserMobProxyServer(net.lightbody.bmp.BrowserMobProxyServer) HttpMessageContents(net.lightbody.bmp.util.HttpMessageContents)

Example 15 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)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