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

How to use
setHttpProxy
method
in
org.openqa.selenium.Proxy

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

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: alfa-laboratory/akita

/**
 * Создает настойки прокси для запуска драйвера
 */
@Before(order = 1)
public void setDriverProxy() {
  if (!Strings.isNullOrEmpty(System.getProperty("proxy"))) {
    Proxy proxy = new Proxy().setHttpProxy(System.getProperty("proxy"));
    setProxy(proxy);
    log.info("Проставлена прокси: " + proxy);
  }
}
origin: net.lightbody.bmp/browsermob-core

/**
 * Creates a Selenium Proxy object using the specified connectableAddressAndPort as the HTTP proxy server.
 *
 * @param connectableAddressAndPort the network address (or hostname) and port the Selenium Proxy will use to reach its
 *                                  proxy server (the InetSocketAddress may be unresolved).
 * @return a Selenium Proxy instance, configured to use the specified address and port as its proxy server
 */
public static org.openqa.selenium.Proxy createSeleniumProxy(InetSocketAddress connectableAddressAndPort) {
  Proxy proxy = new Proxy();
  proxy.setProxyType(Proxy.ProxyType.MANUAL);
  String proxyStr = String.format("%s:%d", connectableAddressAndPort.getHostString(), connectableAddressAndPort.getPort());
  proxy.setHttpProxy(proxyStr);
  proxy.setSslProxy(proxyStr);
  return proxy;
}
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: 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: groupon/odo

public org.openqa.selenium.Proxy seleniumProxy() throws UnknownHostException {
  Proxy proxy = new Proxy();
  proxy.setProxyType(Proxy.ProxyType.MANUAL);
  String proxyStr = String.format("%s:%d", getLocalHost().getCanonicalHostName(), getPort());
  proxy.setHttpProxy(proxyStr);
  proxy.setSslProxy(proxyStr);
  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: 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: 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.github.becauseQA/becauseQA-utils

/**
 * @Title: browserProxySettings @Description: TODO @author
 *         alterhu2020@gmail.com @param @param capability @param @param
 *         proxysettings @return void return type @throws
 */
public static void ProxySettings(DesiredCapabilities capability, String proxysettings) {
  org.openqa.selenium.Proxy httpproxy = new org.openqa.selenium.Proxy();
  httpproxy.setHttpProxy(proxysettings);
  httpproxy.setSslProxy(proxysettings);
  httpproxy.setNoProxy("localhost");
  capability.setCapability(CapabilityType.PROXY, httpproxy);
}
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: com.github.becausetesting/commons

/**
 * @Title: browserProxySettings @Description: TODO @author
 *         alterhu2020@gmail.com @param @param capability @param @param
 *         proxysettings @return void return type @throws
 */
public static void ProxySettings(DesiredCapabilities capability, String proxysettings) {
  org.openqa.selenium.Proxy httpproxy = new org.openqa.selenium.Proxy();
  httpproxy.setHttpProxy(proxysettings);
  httpproxy.setSslProxy(proxysettings);
  httpproxy.setNoProxy("localhost");
  capability.setCapability(CapabilityType.PROXY, httpproxy);
}
origin: com.axway.ats.framework/ats-uiengine

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));
  }
}
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.jspringbot/jspringbot-selenium

@Override
public void afterPropertiesSet() throws Exception {
  if(enable) {
    server = new BrowserMobProxyServer();
    server.start();
    int port = server.getPort();
    Proxy proxy = ClientUtil.createSeleniumProxy(server);
    proxy.setHttpProxy("127.0.0.1:" + port);
    proxy.setSslProxy("127.0.0.1:" + port);
    capabilities.setCapability(CapabilityType.PROXY, proxy);
    System.out.println("BrowserMobProxyServer@" + port);
  }
}
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();
origin: timurstrekalov/saga

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;
}
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: 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);
}
org.openqa.seleniumProxysetHttpProxy

Javadoc

Specify which proxy to use for HTTP connections.

Popular methods of Proxy

  • <init>
  • 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.
  • setAutodetect
    Specifies whether to autodetect proxy settings.
  • 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)
  • Top plugins for WebStorm
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