org.openqa.selenium.Proxy.setFtpProxy()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(273)

本文整理了Java中org.openqa.selenium.Proxy.setFtpProxy()方法的一些代码示例,展示了Proxy.setFtpProxy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Proxy.setFtpProxy()方法的具体详情如下:
包路径:org.openqa.selenium.Proxy
类名称:Proxy
方法名:setFtpProxy

Proxy.setFtpProxy介绍

[英]Specify which proxy to use for FTP connections.
[中]指定用于FTP连接的代理。

代码示例

代码示例来源:origin: org.jspringbot/jspringbot-selenium

public void setFtpProxy(String proxyHost) {
  if (!StringUtils.equalsIgnoreCase(proxyHost, "none")) {
    proxy = new Proxy();
    proxy.setFtpProxy(proxyHost);
    capabilities.setCapability(CapabilityType.PROXY, proxy);
  }
}

代码示例来源:origin: qaprosoft/carina

protected Proxy setupProxy() {
  ProxyPool.setupBrowserMobProxy();
  SystemProxy.setupProxy();
  
  String proxyHost = Configuration.get(Parameter.PROXY_HOST);
  String proxyPort = Configuration.get(Parameter.PROXY_PORT);
  List<String> protocols = Arrays.asList(Configuration.get(Parameter.PROXY_PROTOCOLS).split("[\\s,]+"));
  if (proxyHost != null && !proxyHost.isEmpty() && proxyPort != null && !proxyPort.isEmpty()) {
    org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
    String proxyAddress = String.format("%s:%s", proxyHost, proxyPort);
    if (protocols.contains("http")) {
      LOGGER.info(String.format("Http proxy will be set: %s:%s", proxyHost, proxyPort));
      proxy.setHttpProxy(proxyAddress);
    }
    if (protocols.contains("https")) {
      LOGGER.info(String.format("Https proxy will be set: %s:%s", proxyHost, proxyPort));
      proxy.setSslProxy(proxyAddress);
    }
    if (protocols.contains("ftp")) {
      LOGGER.info(String.format("FTP proxy will be set: %s:%s", proxyHost, proxyPort));
      proxy.setFtpProxy(proxyAddress);
    }
    if (protocols.contains("socks")) {
      LOGGER.info(String.format("Socks proxy will be set: %s:%s", proxyHost, proxyPort));
      proxy.setSocksProxy(proxyAddress);
    }
    return proxy;
  }
  return null;
}

代码示例来源:origin: org.jspringbot/jspringbot-selenium

public void setProxy(String proxyHost) {
  if (!StringUtils.equalsIgnoreCase(proxyHost, "none")) {
    proxy = new Proxy();
    proxy.setFtpProxy(proxyHost)
        .setHttpProxy(proxyHost)
        .setSslProxy(proxyHost);
    capabilities.setCapability(CapabilityType.PROXY, proxy);
  }
}

代码示例来源:origin: org.seleniumhq.selenium/selenium-api

setFtpProxy((String) raw.get("ftpProxy"));

代码示例来源:origin: paypal/SeLion

/**
 * @return - A {@link Proxy} object that represents the Proxy server to be used.
 */
public static Proxy createProxyObject() {
  Proxy proxy = new Proxy();
  String proxyHost = String.format("%s:%s", getProperty(ConfigProperty.SELENIUM_PROXY_HOST),
      getProperty(ConfigProperty.SELENIUM_PROXY_PORT));
  proxy.setHttpProxy(proxyHost);
  proxy.setFtpProxy(proxyHost);
  proxy.setSslProxy(proxyHost);
  return proxy;
}

代码示例来源:origin: com.technophobia.substeps/webdriver-substeps

private void setNetworkCapabilities(final DesiredCapabilities capabilities) {
  final String proxyHost = configuration.getNetworkProxyHost();
  if (StringUtils.isNotEmpty(proxyHost)) {
    final int proxyPort = configuration.getNetworkProxyPort();
    final String proxyHostAndPort = proxyHost + ":" + proxyPort;
    final org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
    proxy.setHttpProxy(proxyHostAndPort).setFtpProxy(proxyHostAndPort).setSslProxy(proxyHostAndPort);
    capabilities.setCapability(CapabilityType.PROXY, proxy);
    LOG.info("Proxy set to {}", proxyHostAndPort);
  }
}

代码示例来源:origin: Frameworkium/frameworkium-core

private static Proxy createManualProxy(String proxyProperty) {
  String proxyString = getProxyURL(proxyProperty);
  logger.debug("All protocols to use proxy address: {}", proxyString);
  Proxy proxy = new Proxy();
  proxy.setProxyType(Proxy.ProxyType.MANUAL)
      .setHttpProxy(proxyString)
      .setFtpProxy(proxyString)
      .setSslProxy(proxyString);
  return proxy;
}

代码示例来源:origin: tarun3kumar/seleniumtestsframework

public Proxy getProxy() {
  Proxy proxy = null;
  if (proxyHost != null) {
    proxy = new Proxy();
    proxy.setProxyType(ProxyType.MANUAL);
    proxy.setHttpProxy(proxyHost);
    proxy.setFtpProxy(proxyHost);
    proxy.setSslProxy(proxyHost);
  }
  return proxy;
}

代码示例来源:origin: org.paxml/PaxmlSelenium

proxy.setFtpProxy(proxyFtp);

代码示例来源:origin: org.paxml/paxml-selenium

proxy.setFtpProxy(proxyFtp);

代码示例来源:origin: org.finra.jtaf/jtaf-extwebdriver

if (proxyProperty != null) {
  Proxy proxy = new Proxy();
  proxy.setHttpProxy(proxyProperty).setFtpProxy(proxyProperty).setSslProxy(
      proxyProperty);
  desiredCapabilities = new DesiredCapabilities();

代码示例来源:origin: FINRAOS/JTAF-ExtWebDriver

if (proxyProperty != null) {
  Proxy proxy = new Proxy();
  proxy.setHttpProxy(proxyProperty).setFtpProxy(proxyProperty).setSslProxy(
      proxyProperty);
  desiredCapabilities = new DesiredCapabilities();

代码示例来源:origin: org.unitils.selenium/unitils-selenium

/**
 * Creates the DesiredCapabilities for an IE WebDriver.
 * @param proxyUrl
 * @return DesiredCapabilities
 */
protected static DesiredCapabilities createCapabilitiesIE(String proxyUrl) {
  DesiredCapabilities cap = DesiredCapabilities.internetExplorer();
  cap.setCapability(CapabilityType.LOGGING_PREFS, createLoggingPreferences());
  cap.setCapability("ignoreProtectedModeSettings", true);
  cap.setCapability("ignoreZoomSetting", true);
  if (StringUtils.isNotEmpty(proxyUrl)) {
    Proxy proxy = new Proxy();
    proxy.setHttpProxy(proxyUrl).setFtpProxy(proxyUrl).setSslProxy(proxyUrl).setNoProxy("");
    cap.setCapability(CapabilityType.PROXY, proxy);
  }
  return cap;
}

代码示例来源:origin: org.unitils.selenium/unitils-selenium

/**
 * Creates the DesiredCapabilities for firefox.
 * @param proxyUrl
 * @param profile
 * @return DesiredCapabilities
 */
protected static DesiredCapabilities createCapabilitesFirefox(String proxyUrl, FirefoxProfile profile) {
  DesiredCapabilities capabilities = DesiredCapabilities.firefox();
  if (!proxyUrl.isEmpty()) {
    capabilities.setCapability(FirefoxDriver.PROFILE, profile);
    profile.setPreference("network.proxy.type", 1);
    Proxy proxy = new Proxy();
    proxy.setHttpProxy(proxyUrl).setFtpProxy(proxyUrl).setSslProxy(proxyUrl).setNoProxy("");
    capabilities.setCapability(CapabilityType.PROXY, proxy);
  }
  capabilities.setCapability(CapabilityType.LOGGING_PREFS, createLoggingPreferences());
  return capabilities;
}

代码示例来源:origin: gradle.plugin.GoBqa/gradle-plugin

proxy.setHttpProxy(PROXY).setFtpProxy(PROXY).setSslProxy(PROXY).setSocksProxy(PROXY);
cap.setCapability(CapabilityType.PROXY, proxy);

代码示例来源:origin: vmi/selenese-runner-java

/**
 * Create new Proxy from driver options.
 *
 * @param driverOptions driver options.
 * @return Proxy or null.
 */
public static Proxy newProxy(DriverOptions driverOptions) {
  if (!driverOptions.has(PROXY))
    return null;
  Proxy proxy = new Proxy();
  proxy.setProxyType(ProxyType.MANUAL);
  String ps = driverOptions.get(PROXY);
  proxy.setHttpProxy(ps)
    .setSslProxy(ps)
    .setFtpProxy(ps);
  if (driverOptions.has(NO_PROXY))
    proxy.setNoProxy(driverOptions.get(NO_PROXY));
  return proxy;
}

代码示例来源:origin: kg.apc/jmeter-plugins-webdriver

/**
 * This returns a {@link Proxy} with HTTP, HTTPS and FTP hosts and ports configured as specified.
 *
 *
 * @param httpProxy is the http proxy host and port
 * @param httpsProxy is the https proxy host and port
 * @param ftpProxy is the ftp proxy host and port
 * @param socksProxy is the socks proxy host and port
 * @param noProxy is a comma separated list of hosts that will bypass the proxy
 *
 * @return a proxy object with the hosts manually specified.
 */
public Proxy getManualProxy(ProxyHostPort httpProxy, ProxyHostPort httpsProxy, ProxyHostPort ftpProxy, ProxyHostPort socksProxy, String noProxy) {
  return new Proxy()
    .setProxyType(Proxy.ProxyType.MANUAL)
    .setHttpProxy(httpProxy.toUnifiedForm())
    .setSslProxy(httpsProxy.toUnifiedForm())
    .setFtpProxy(ftpProxy.toUnifiedForm())
    .setSocksProxy(socksProxy.toUnifiedForm())
    .setNoProxy(noProxy);
}

代码示例来源:origin: org.bitbucket.iamkenos/cissnei-selenium

proxy.setFtpProxy(wdProxy).setHttpProxy(wdProxy).setSslProxy(wdProxy);
options.setCapability(PROXY, proxy);

代码示例来源:origin: org.bitbucket.iamkenos/cissnei-selenium

proxy.setFtpProxy(wdProxy).setHttpProxy(wdProxy).setSslProxy(wdProxy);
options.setCapability(PROXY, proxy);

代码示例来源:origin: com.infotel.seleniumRobot/core

public Proxy getProxy() {
  ProxyConfig proxyConfig = getProxyConfig();
  
  Proxy proxy = new Proxy();
  proxy.setProxyType(proxyConfig.getType());
  
  if (proxyConfig.getType() == ProxyType.PAC) {
    proxy.setProxyAutoconfigUrl(proxyConfig.getPac());
    
  // manual proxy configuration
  } else if (proxyConfig.getType() == ProxyType.MANUAL) {
    proxy.setHttpProxy(proxyConfig.getAddressAndPort());
    proxy.setSslProxy(proxyConfig.getAddressAndPort());
    proxy.setFtpProxy(proxyConfig.getAddressAndPort());
    
    if (proxyConfig.getLogin() != null && proxyConfig.getPassword() != null) {
      proxy.setSocksUsername(proxyConfig.getLogin());
      proxy.setSocksPassword(proxyConfig.getPassword());
    }
    
    if (proxyConfig.getExclude() != null) {
      proxy.setNoProxy(proxyConfig.getExclude().replace(";", ","));
    }
  }     
  
  return proxy;
}

相关文章