當前位置: 首頁>>代碼示例>>Java>>正文


Java Proxy類代碼示例

本文整理匯總了Java中org.openqa.selenium.Proxy的典型用法代碼示例。如果您正苦於以下問題:Java Proxy類的具體用法?Java Proxy怎麽用?Java Proxy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Proxy類屬於org.openqa.selenium包,在下文中一共展示了Proxy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getProxy

import org.openqa.selenium.Proxy; //導入依賴的package包/類
private Proxy getProxy() {
    ProxyServer server = getServer();

    server.setCaptureContent(true);
    server.setCaptureHeaders(true);

    SeleniumHolder.setProxyServer(server);

    Proxy proxy = new Proxy();

    try {
        proxy = server.seleniumProxy();
        String localIp = InetAddress.getLocalHost().getHostAddress();
        String proxyStr = String.format("%s:%d", localIp, server.getPort());
        proxy.setHttpProxy(proxyStr);
        proxy.setSslProxy("trustAllSSLCertificates");
        proxy.setFtpProxy(proxyStr);
        SeleniumHolder.setProxy(proxy);
    } catch (UnknownHostException e) {
        LOGGER.error("UnknownHostException occurs", e);
    }
    return proxy;
}
 
開發者ID:WileyLabs,項目名稱:teasy,代碼行數:24,代碼來源:SeleniumTestExecutionListener.java

示例2: getProxyDriverIntegrator

import org.openqa.selenium.Proxy; //導入依賴的package包/類
private ProxyDriverIntegrator getProxyDriverIntegrator(RequestFilter recordRequestFilter,
                                                       WebDriverSupplier webDriverSupplier,
                                                       DriverServiceSupplier driverServiceSupplier,
                                                       @Named(PATH_TO_DRIVER) String pathToDriverExecutable,
                                                       @Named(SCREEN) String screen,
                                                       @Named(TIMEOUT) int timeout,
                                                       ResponseFilter responseFilter) throws IOException {
    BrowserMobProxy proxy = createBrowserMobProxy(timeout, recordRequestFilter, responseFilter);
    proxy.start(0);
    logger.info("Proxy running on port " + proxy.getPort());
    Proxy seleniumProxy = createSeleniumProxy(proxy);
    DesiredCapabilities desiredCapabilities = createDesiredCapabilities(seleniumProxy);
    DriverService driverService = driverServiceSupplier.getDriverService(pathToDriverExecutable, screen);
    WebDriver driver = webDriverSupplier.get(driverService, desiredCapabilities);

    return new ProxyDriverIntegrator(driver, proxy, driverService);
}
 
開發者ID:hristo-vrigazov,項目名稱:bromium,代碼行數:18,代碼來源:DefaultModule.java

示例3: createDefaultService

import org.openqa.selenium.Proxy; //導入依賴的package包/類
public static PhantomJSDriverService createDefaultService(Capabilities desiredCapabilities, Map<String, String> env) {
	Proxy proxy = null;
	if (desiredCapabilities != null) {
		proxy = Proxy.extractFrom(desiredCapabilities);
	}

	File phantomjsfile = findPhantomJS(desiredCapabilities, "https://github.com/ariya/phantomjs/wiki", "http://phantomjs.org/download.html");
	File ghostDriverfile = findGhostDriver(desiredCapabilities, "https://github.com/detro/ghostdriver/blob/master/README.md", "https://github.com/detro/ghostdriver/downloads");
	Builder builder = new Builder();
	builder.usingPhantomJSExecutable(phantomjsfile)
		.usingGhostDriver(ghostDriverfile)
		.usingAnyFreePort()
		.withProxy(proxy)
		.withLogFile(new File("phantomjsdriver.log"))
		.usingCommandLineArguments(findCLIArgumentsFromCaps(desiredCapabilities, "phantomjs.cli.args"))
		.usingGhostDriverCommandLineArguments(findCLIArgumentsFromCaps(desiredCapabilities, "phantomjs.ghostdriver.cli.args"));
	if(null != env)
		builder.withEnvironment(env);
	return builder.build();
}
 
開發者ID:fjalvingh,項目名稱:domui,代碼行數:21,代碼來源:MyPhantomDriverService.java

示例4: getWebClient

import org.openqa.selenium.Proxy; //導入依賴的package包/類
private WebDriver getWebClient(int portForJSCoverProxy) {
    Proxy proxy = new Proxy().setHttpProxy("localhost:" + portForJSCoverProxy);
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability(CapabilityType.PROXY, proxy);
    caps.setJavascriptEnabled(true);
    caps.setBrowserName(BrowserType.HTMLUNIT);
    return new HtmlUnitDriver(caps) {
        @Override
        protected WebClient modifyWebClient(WebClient client) {
            client.setScriptPreProcessor((htmlPage, sourceCode, sourceName, lineNumber, htmlElement) -> {
                if(removeJsSnippets != null && !removeJsSnippets.isEmpty()) {
                    for(String toReplace : removeJsSnippets) {
                        sourceCode = sourceCode.replace(toReplace, "");
                    }
                    return sourceCode;
                } else {
                    return sourceCode;
                }

            });
            return client;
        }
    };
}
 
開發者ID:digitalfondue,項目名稱:jscoverproxy-maven-plugin,代碼行數:25,代碼來源:JSCoverProxyMavenMojo.java

示例5: createWebDriver

import org.openqa.selenium.Proxy; //導入依賴的package包/類
@Override
public WebCommunicationWrapper createWebDriver(ProxyServerWrapper proxyServer)
    throws WorkerException {
  try {
    Proxy proxy = proxyServer.seleniumProxy();
    proxyServer.setCaptureContent(true);
    proxyServer.setCaptureHeaders(true);

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.PROXY, proxy);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

    FirefoxProfile fp = getFirefoxProfile();
    fp.setAcceptUntrustedCertificates(true);
    fp.setAssumeUntrustedCertificateIssuer(false);
    capabilities.setCapability(AetFirefoxDriver.PROFILE, fp);

    return new WebCommunicationWrapperImpl(getFirefoxDriver(fp, capabilities), proxyServer,
        requestExecutorFactory
            .createInstance());
  } catch (Exception e) {
    throw new WorkerException(e.getMessage(), e);
  }
}
 
開發者ID:Cognifide,項目名稱:aet,代碼行數:25,代碼來源:FirefoxWebDriverFactory.java

示例6: JFunkHtmlUnitDriverImpl

import org.openqa.selenium.Proxy; //導入依賴的package包/類
protected JFunkHtmlUnitDriverImpl(final BrowserVersion browserVersion, final HtmlUnitWebDriverParams webDriverParams,
		final AjaxController ajaxController, final HtmlUnitSSLParams sslParams,
		final Map<String, CredentialsProvider> credentialsProviderMap,
		final Provider<DumpFileCreator> htmlFileCreatorProvider, final Provider<File> moduleArchiveDirProvider,
		final Provider<Set<WebWindowListener>> listenersProvider, final Proxy proxy) {

	super(browserVersion);

	this.webDriverParams = webDriverParams;
	this.sslParams = sslParams;
	this.ajaxController = ajaxController;
	this.credentialsProviderMap = credentialsProviderMap;
	this.htmlFileCreatorProvider = htmlFileCreatorProvider;
	this.moduleArchiveDirProvider = moduleArchiveDirProvider;
	this.listenersProvider = listenersProvider;

	setProxy(proxy);
	setJavascriptEnabled(webDriverParams.isJavascriptEnabled());

	// cannot override modifyWebClient because it is called in the super class' constructor before our params are set
	configureWebClient(getWebClient());
}
 
開發者ID:mgm-tp,項目名稱:jfunk,代碼行數:23,代碼來源:JFunkHtmlUnitDriverImpl.java

示例7: setupFirefox

import org.openqa.selenium.Proxy; //導入依賴的package包/類
private static void setupFirefox() {
	final DesiredCapabilities capabilities = new DesiredCapabilities();
	final String proxyHost = System.getProperty("http.proxyHost");
	final String proxyPort = System.getProperty("http.proxyPort");
	if (proxyHost != null) {
		System.out
				.println("Configuring Firefox Selenium web driver with proxy "
						+ proxyHost
						+ (proxyPort == null ? "" : ":" + proxyPort)
						+ " (requires Firefox browser)");
		final Proxy proxy = new Proxy();
		final String proxyString = proxyHost
				+ (proxyPort == null ? "" : ":" + proxyPort);
		proxy.setHttpProxy(proxyString).setSslProxy(proxyString);
		proxy.setNoProxy("localhost");
		capabilities.setCapability(CapabilityType.PROXY, proxy);
	} else {
		System.out
				.println("Configuring Firefox Selenium web driver without proxy (requires Firefox browser)");
	}

	driver = new FirefoxDriver(capabilities);
	driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
 
開發者ID:SAP,項目名稱:cloud-personslist-scenario,代碼行數:25,代碼來源:UiTestBase.java

示例8: configureProxy

import org.openqa.selenium.Proxy; //導入依賴的package包/類
private void configureProxy(final ITestContext context, final Method method) {
    final MonitorNetwork monitorNetwork = method.getAnnotation(MonitorNetwork.class);

    if (monitorNetwork != null && monitorNetwork.enabled()) {
        final String initialPageID = context.getName() + " : " + method.getName();
        harDetailsLink = HAR_STORAGE.getHarDetailsURL(initialPageID);

        proxy = new BrowserMobProxy(PROXY_IP, PROXY_PORT);
        proxy.setSocketOperationTimeout(DEFAULT_SOCKET_TIMEOUT);
        proxy.setRequestTimeout(DEFAULT_REQUEST_TIMEOUT);

        // Getting port for Selenium proxy
        final int port = proxy.getPort();
        proxy.setPort(port);

        // Creating har on raised proxy for monitoring net statistics before first page is loaded.
        proxy.newHar(initialPageID, monitorNetwork.captureHeaders(), monitorNetwork.captureContent(),
                monitorNetwork.captureBinaryContent());

        // Get the Selenium proxy object
        final String actualProxy = PROXY_IP + ":" + port;
        seleniumProxy = new Proxy();
        seleniumProxy.setHttpProxy(actualProxy).setFtpProxy(actualProxy)
                .setSslProxy(actualProxy);
    }
}
 
開發者ID:atinfo,項目名稱:at.info-knowledge-base,代碼行數:27,代碼來源:BaseTest.java

示例9: setFirefoxProxyIfAvailable

import org.openqa.selenium.Proxy; //導入依賴的package包/類
private void setFirefoxProxyIfAvailable(
                                         DesiredCapabilities capabilities ) {

    if (!StringUtils.isNullOrEmpty(AtsSystemProperties.SYSTEM_HTTP_PROXY_HOST)
        && !StringUtils.isNullOrEmpty(AtsSystemProperties.SYSTEM_HTTP_PROXY_PORT)) {

        capabilities.setCapability(CapabilityType.PROXY,
                                   new Proxy().setHttpProxy(AtsSystemProperties.SYSTEM_HTTP_PROXY_HOST
                                                            + ':'
                                                            + AtsSystemProperties.SYSTEM_HTTP_PROXY_PORT));
    }
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:13,代碼來源:AbstractRealBrowserDriver.java

示例10: addProxy

import org.openqa.selenium.Proxy; //導入依賴的package包/類
@Override
public CapabilitiesBuilder addProxy(String host, int port)
{
    Proxy proxy = new Proxy();
    proxy.setHttpProxy("host" + ":" + port);

    capabilities.setCapability("proxy", proxy);

    return this;
}
 
開發者ID:pradeeptaswain,項目名稱:oldmonk,代碼行數:11,代碼來源:WebCapabilitiesBuilder.java

示例11: setProxyTo

import org.openqa.selenium.Proxy; //導入依賴的package包/類
private void setProxyTo(DesiredCapabilities capabilities, Map<String,
        String> proxyProperties) {
    Proxy proxy = new Proxy();
    boolean isEnable = false;
    try {
        String enableParam = System.getProperty("zap.enable");
        isEnable = Boolean.parseBoolean(enableParam);
    } catch (Exception ex) {
        LOGGER.error("\"NullPointerException = \" + ex.getMessage()");
    }


    String host = proxyProperties.get(ProxyProperty.ZAP_PROXY_HOST
            .toString());
    String port = proxyProperties.get(ProxyProperty.ZAP_PROXY_PORT
            .toString());

    if (!isEnable) {
        LOGGER.error("Proxy will not be set: " + " = " + isEnable);
        return;
    }
    proxy.setHttpProxy(host + ":" + port);
    proxy.setSocksProxy(host + ":" + port);
    proxy.setFtpProxy(host + ":" + port);
    proxy.setSslProxy(host + ":" + port);
    proxy.setProxyType(ProxyType.MANUAL);

    capabilities.setCapability(CapabilityType.PROXY, proxy);
}
 
開發者ID:tapack,項目名稱:satisfy,代碼行數:30,代碼來源:ProxyFixture.java

示例12: ZAProxyScanner

import org.openqa.selenium.Proxy; //導入依賴的package包/類
public ZAProxyScanner(String host, int port, String apiKey)
        throws IllegalArgumentException, ProxyException {
    validateHost(host);
    validatePort(port);
    this.apiKey = apiKey;

    clientApi = new ClientApi(host, port, this.apiKey);
    validateMinimumRequiredZapVersion();

    seleniumProxy = new Proxy();
    seleniumProxy.setProxyType(Proxy.ProxyType.PAC);
    StringBuilder strBuilder = new StringBuilder();
    strBuilder.append("http://").append(host).append(":").append(port).append("/proxy.pac?apikey=").append(this.apiKey);
    seleniumProxy.setProxyAutoconfigUrl(strBuilder.toString());
}
 
開發者ID:AgileTestingFramework,項目名稱:atf-toolbox-java,代碼行數:16,代碼來源:ZAProxyScanner.java

示例13: proxyCapabilities

import org.openqa.selenium.Proxy; //導入依賴的package包/類
DesiredCapabilities proxyCapabilities(BrowserMobProxy browserMobProxy) {
  browserMobProxy.enableHarCaptureTypes(
      CaptureType.REQUEST_HEADERS,
      CaptureType.RESPONSE_HEADERS,
      CaptureType.REQUEST_CONTENT,
      CaptureType.RESPONSE_CONTENT);

  Proxy seleniumProxy = ClientUtil.createSeleniumProxy(browserMobProxy);
  DesiredCapabilities capabilities = new DesiredCapabilities();
  capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
  return capabilities;
}
 
開發者ID:Cognifide,項目名稱:bobcat,代碼行數:13,代碼來源:AbstractProxyTest.java

示例14: enableProxy

import org.openqa.selenium.Proxy; //導入依賴的package包/類
private DesiredCapabilities enableProxy(Capabilities capabilities) {
  DesiredCapabilities caps = new DesiredCapabilities(capabilities);
  try {
    InetAddress proxyInetAddress = InetAddress.getByName(proxyIp);
    BrowserMobProxy browserMobProxy = proxyController.startProxyServer(proxyInetAddress);
    Proxy seleniumProxy = ClientUtil.createSeleniumProxy(browserMobProxy, proxyInetAddress);
    caps.setCapability(CapabilityType.PROXY, seleniumProxy);
  } catch (UnknownHostException e) {
    throw new IllegalStateException(e);
  }
  return caps;
}
 
開發者ID:Cognifide,項目名稱:bobcat,代碼行數:13,代碼來源:EnableProxy.java

示例15: setOptionalProxyConfiguration

import org.openqa.selenium.Proxy; //導入依賴的package包/類
private void setOptionalProxyConfiguration(DesiredCapabilities capabilities) {
    if (proxyConfiguration != null) {
        Proxy proxy = new Proxy();
        proxyConfiguration.configureProxy(proxy);
        capabilities.setCapability(CapabilityType.PROXY, proxy);
    }
}
 
開發者ID:testIT-WebTester,項目名稱:webtester2-core,代碼行數:8,代碼來源:RemoteFactory.java


注:本文中的org.openqa.selenium.Proxy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。