Tabnine Logo
Proxy
Code IndexAdd Tabnine to your IDE (free)

How to use
Proxy
in
org.openqa.selenium

Best Java code snippets using org.openqa.selenium.Proxy (Showing top 20 results out of 369)

origin: detro/ghostdriver

proxy = Proxy.extractFrom(desiredCapabilities);
origin: detro/ghostdriver

switch (proxy.getProxyType()) {
  case MANUAL:
    if (proxy.getHttpProxy() != null && !proxy.getHttpProxy().isEmpty()) {          //< HTTP proxy
      argsBuilder.add("--proxy-type=http");
      argsBuilder.add(String.format("--proxy=%s", proxy.getHttpProxy()));
    } else if (proxy.getSocksProxy() != null && !proxy.getSocksProxy().isEmpty()) {  //< SOCKS5 proxy
      argsBuilder.add("--proxy-type=socks5");
      argsBuilder.add(String.format("--proxy=%s", proxy.getSocksProxy()));
      if (proxy.getSocksUsername() != null && !proxy.getSocksUsername().isEmpty()
          && proxy.getSocksPassword() != null && !proxy.getSocksPassword().isEmpty()) {
        argsBuilder.add(String.format("--proxy-auth=%s:%s", proxy.getSocksUsername(),
            proxy.getSocksPassword()));
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

private WebDriver createWebDriver(Context context) {
  Proxy proxy = new Proxy();
  if (StringUtils.isNotBlank(proxyHttp)) {
    proxy.setHttpProxy(proxyHttp);
    proxy.setFtpProxy(proxyFtp);
    proxy.setSslProxy(proxySsl);
    proxy.setProxyAutoconfigUrl(proxyAutoConfigUrl);
    proxy.setAutodetect(proxyAutoDetect);
origin: net.serenity-bdd/serenity-core

  public void in(DesiredCapabilities capabilities) {
    String proxyUrl = ThucydidesSystemProperty.SERENITY_PROXY_HTTP.from(environmentVariables);
    String proxyPort = ThucydidesSystemProperty.SERENITY_PROXY_HTTP_PORT.from(environmentVariables);
    String sslProxy = ThucydidesSystemProperty.SERENITY_PROXY_SSL.from(environmentVariables, proxyUrl);
    String sslProxyPort = ThucydidesSystemProperty.SERENITY_PROXY_SSL_PORT.from(environmentVariables);

    Proxy proxy = new Proxy();

    if ((proxyUrl  != null) && (!proxyUrl.isEmpty())) {
      JsonObject json = new JsonObject();
      if (StringUtils.isNotEmpty(proxyUrl)) {
        proxy.setHttpProxy(proxyUrl + ":"+ proxyPort);
      }
      if (StringUtils.isNotEmpty(sslProxy)) {
        proxy.setSslProxy(sslProxy + ":"+ sslProxyPort);
      }
      if (StringUtils.isNotEmpty(sslProxyPort)) {
        json.addProperty("sslProxyPort", sslProxyPort);
      }
      capabilities.setCapability(CapabilityType.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;
}
origin: org.seleniumhq.selenium/selenium-api

public Proxy(Map<String, ?> raw) {
 if (raw.containsKey("proxyType") && raw.get("proxyType") != null) {
  setProxyType(ProxyType.valueOf(((String) raw.get("proxyType")).toUpperCase()));
  setFtpProxy((String) raw.get("ftpProxy"));
  setHttpProxy((String) raw.get("httpProxy"));
  if (rawData instanceof List) {
   setNoProxy(String.join(", ", (List) rawData));
  } else {
   setNoProxy((String) rawData);
  setSslProxy((String) raw.get("sslProxy"));
  setSocksProxy((String) raw.get("socksProxy"));
  setSocksVersion((Integer) raw.get("socksVersion"));
  setSocksUsername((String) raw.get("socksUsername"));
  setSocksPassword((String) raw.get("socksPassword"));
  setProxyAutoconfigUrl((String) raw.get("proxyAutoconfigUrl"));
  setAutodetect((Boolean) raw.get("autodetect"));
origin: org.jspringbot/jspringbot-selenium

public void setHttpProxy(String proxyHost) {
  if (!StringUtils.equalsIgnoreCase(proxyHost, "none")) {
    proxy = new Proxy();
    proxy.setHttpProxy(proxyHost);
    capabilities.setCapability(CapabilityType.PROXY, proxy);
  }
}
origin: com.github.detro/browsermob-proxy-client

/**
 * Returns the Proxy this client wraps, in form of a Selenium Proxy configuration object.
 *
 * @return Selenium Proxy configuration object
 */
public Proxy asSeleniumProxy() {
  Proxy seleniumProxyConfig = new Proxy();
  seleniumProxyConfig.setProxyType(Proxy.ProxyType.MANUAL);
  seleniumProxyConfig.setHttpProxy(asHostAndPort());
  return seleniumProxyConfig;
}
origin: com.opera/operadriver

 Proxy sanitize(Object proxy) {
  if (proxy != null) {
   if (proxy instanceof Proxy) {
    return (Proxy) proxy;
   } else if (proxy instanceof Map) {
    return new Proxy((Map<String, ?>) proxy);
   }
  }
  return null;
 }
},
origin: Cognifide/aet

@Override
public Proxy seleniumProxy() throws UnknownHostException {
 return server.asSeleniumProxy()
   .setHttpProxy(String.format("%s:%d", proxyManager.getServer(), getPort()))
   .setSslProxy(String.format("%s:%d", proxyManager.getServer(), getPort()));
}
origin: kg.apc/jmeter-plugins-webdriver

/**
 * This will not use a proxy and expects a direct connection to the internet.
 *
 * @return a proxy object that does not use proxies.
 */
public Proxy getDirectProxy() {
  return new Proxy()
    .setProxyType(Proxy.ProxyType.DIRECT);
}
origin: org.jspringbot/jspringbot-selenium

public void setSslProxy(String proxyHost) {
  if (!StringUtils.equalsIgnoreCase(proxyHost, "none")) {
    proxy = new Proxy();
    proxy.setSslProxy(proxyHost);
    capabilities.setCapability(CapabilityType.PROXY, proxy);
  }
}
origin: zc-zh-001/ShadowSocks-Share

Proxy proxy = new Proxy();
  proxy.setSocksProxy(proxyServer);
} else {
  proxy.setHttpProxy(proxyServer);
origin: kg.apc/jmeter-plugins-webdriver

/**
 * If the proxy can be configured using a PAC file at a URL, set this value to the location of this PAC file.
 *
 * @param pacUrl is the url to the Proxy PAC file
 *
 * @return a proxy object with its proxies configured automatically using a PAC file.
 */
public Proxy getConfigUrlProxy(String pacUrl) {
  return new Proxy()
    .setProxyType(Proxy.ProxyType.PAC)
    .setProxyAutoconfigUrl(pacUrl);
}
origin: kg.apc/jmeter-plugins-webdriver

/**
 * This is a proxy which will have its settings automatically configured.
 *
 * @return a proxy object which will try to automatically detect the proxy settings.
 */
public Proxy getAutodetectProxy() {
  return new Proxy()
    .setProxyType(Proxy.ProxyType.AUTODETECT)
    .setAutodetect(true);
}
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: org.seleniumhq.selenium/selenium-api

 @Override
 public int hashCode() {
  return Objects.hash(
    getProxyType(),
    isAutodetect(),
    getFtpProxy(),
    getHttpProxy(),
    getNoProxy(),
    getSslProxy(),
    getSocksProxy(),
    getSocksVersion(),
    getSocksUsername(),
    getSocksPassword(),
    getProxyAutoconfigUrl());
 }
}
origin: stackoverflow.com

 server = new BrowserMobProxyServer();
server.start(0);
Proxy proxy = ClientUtil.createSeleniumProxy(server);
proxy.setSslProxy("trustAllSSLCertificates");
origin: stackoverflow.com

 String PROXY = "localhost:8080";

  ProxyServer server = new ProxyServer(8080);
  server.start();

  Proxy proxy = server.seleniumProxy();
  proxy.setHttpProxy(PROXY).setFtpProxy(PROXY).setSslProxy(PROXY);

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

  WebDriver driver = new FirefoxDriver(capabilities);

  server.newHar("yahoo.com");

  driver.get("http://yahoo.com");


  Har har = server.getHar();
FileOutputStream fos = new                           FileOutputStream("C:\\Users\\ner\\output.txt");
  har.writeTo(fos);
  server.stop();
  driver.quit();
org.openqa.seleniumProxy

Javadoc

Configuration parameters for using proxies in WebDriver. Generally you should pass an object of this type to a WebDriver constructor, or in some cases to the profile object used in the WebDriver construction. For simplicity, setting values here commits the proxy to a certain configuration. That is, it is an error to set an httpProxy manually and then turn on proxy autodetect.

Most used methods

  • <init>
  • setHttpProxy
    Specify which proxy to use for HTTP connections.
  • setSslProxy
    Specify which proxy to use for SSL connections.
  • setFtpProxy
    Specify which proxy to use for FTP connections.
  • setProxyType
    Explicitly sets the proxy type, useful for forcing direct connection on Linux.
  • extractFrom
  • getHttpProxy
    Gets the HTTP proxy.
  • setNoProxy
    Sets proxy bypass (noproxy) addresses
  • getProxyType
    Gets the ProxyType. This can signal if set to use a direct connection (without proxy), manually set
  • setProxyAutoconfigUrl
    Specifies the URL to be used for proxy auto-configuration. Expected format is http://hostname.com:12
  • setSocksProxy
    Specifies which proxy to use for SOCKS.
  • getSocksProxy
    Gets the SOCKS proxy.
  • setSocksProxy,
  • getSocksProxy,
  • setAutodetect,
  • getProxyAutoconfigUrl,
  • getSocksPassword,
  • getSocksUsername,
  • getFtpProxy,
  • getNoProxy,
  • setSocksPassword,
  • setSocksUsername

Popular in Java

  • Updating database using SQL prepared statement
  • findViewById (Activity)
  • scheduleAtFixedRate (Timer)
  • requestLocationUpdates (LocationManager)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • JPanel (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now