Package org.openqa.selenium
Class Proxy
- java.lang.Object
-
- org.openqa.selenium.Proxy
-
public class Proxy extends java.lang.Object
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 anhttpProxy
manually and then turn on proxy autodetect.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Proxy.ProxyType
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
static Proxy
extractFrom(Capabilities capabilities)
java.lang.String
getFtpProxy()
Gets the FTP proxy.java.lang.String
getHttpProxy()
Gets the HTTP proxy.java.lang.String
getNoProxy()
Gets proxy bypass (noproxy) addresses.java.lang.String
getProxyAutoconfigUrl()
Gets the proxy auto-configuration URL.Proxy.ProxyType
getProxyType()
Gets theProxy.ProxyType
.java.lang.String
getSocksPassword()
Gets the SOCKS proxy's password.java.lang.String
getSocksProxy()
Gets the SOCKS proxy.java.lang.String
getSocksUsername()
Gets the SOCKS proxy's username.java.lang.Integer
getSocksVersion()
Gets the SOCKS version (4 or 5).java.lang.String
getSslProxy()
Gets the SSL tunnel proxy.int
hashCode()
boolean
isAutodetect()
Whether to autodetect proxy settings.Proxy
setAutodetect(boolean autodetect)
Specifies whether to autodetect proxy settings.Proxy
setFtpProxy(java.lang.String ftpProxy)
Specify which proxy to use for FTP connections.Proxy
setHttpProxy(java.lang.String httpProxy)
Specify which proxy to use for HTTP connections.Proxy
setNoProxy(java.lang.String noProxy)
Sets proxy bypass (noproxy) addressesProxy
setProxyAutoconfigUrl(java.lang.String proxyAutoconfigUrl)
Specifies the URL to be used for proxy auto-configuration.Proxy
setProxyType(Proxy.ProxyType proxyType)
Explicitly sets the proxy type, useful for forcing direct connection on Linux.Proxy
setSocksPassword(java.lang.String password)
Specifies a password for the SOCKS proxy.Proxy
setSocksProxy(java.lang.String socksProxy)
Specifies which proxy to use for SOCKS.Proxy
setSocksUsername(java.lang.String username)
Specifies a username for the SOCKS proxy.Proxy
setSocksVersion(java.lang.Integer socksVersion)
Specifies which version of SOCKS to use (4 or 5).Proxy
setSslProxy(java.lang.String sslProxy)
Specify which proxy to use for SSL connections.java.util.Map<java.lang.String,java.lang.Object>
toJson()
java.lang.String
toString()
-
-
-
Method Detail
-
toJson
public java.util.Map<java.lang.String,java.lang.Object> toJson()
-
getProxyType
public Proxy.ProxyType getProxyType()
Gets theProxy.ProxyType
. This can signal if set to use a direct connection (without proxy), manually set proxy settings, auto-configured proxy settings, or whether to use the default system proxy settings. It defaults toProxy.ProxyType.UNSPECIFIED
.- Returns:
- the proxy type employed
-
setProxyType
public Proxy setProxyType(Proxy.ProxyType proxyType)
Explicitly sets the proxy type, useful for forcing direct connection on Linux.- Parameters:
proxyType
- type of proxy being used- Returns:
- reference to self
-
isAutodetect
public boolean isAutodetect()
Whether to autodetect proxy settings.- Returns:
- true if set to autodetect proxy settings, false otherwise
-
setAutodetect
public Proxy setAutodetect(boolean autodetect)
Specifies whether to autodetect proxy settings.- Parameters:
autodetect
- set to true to use proxy auto detection, false to leave proxy settings unspecified- Returns:
- reference to self
-
getFtpProxy
public java.lang.String getFtpProxy()
Gets the FTP proxy.- Returns:
- the FTP proxy hostname if present, or null if not set
-
setFtpProxy
public Proxy setFtpProxy(java.lang.String ftpProxy)
Specify which proxy to use for FTP connections.- Parameters:
ftpProxy
- the proxy host, expected format ishostname.com:1234
- Returns:
- reference to self
-
getHttpProxy
public java.lang.String getHttpProxy()
Gets the HTTP proxy.- Returns:
- the HTTP proxy hostname if present, or null if not set
-
setHttpProxy
public Proxy setHttpProxy(java.lang.String httpProxy)
Specify which proxy to use for HTTP connections.- Parameters:
httpProxy
- the proxy host, expected format ishostname:1234
- Returns:
- reference to self
-
getNoProxy
public java.lang.String getNoProxy()
Gets proxy bypass (noproxy) addresses.- Returns:
- The proxy bypass (noproxy) addresses
-
setNoProxy
public Proxy setNoProxy(java.lang.String noProxy)
Sets proxy bypass (noproxy) addresses- Parameters:
noProxy
- The proxy bypass (noproxy) addresses separated by commas- Returns:
- reference to self
-
getSslProxy
public java.lang.String getSslProxy()
Gets the SSL tunnel proxy.- Returns:
- the SSL tunnel proxy hostname if present, null otherwise
-
setSslProxy
public Proxy setSslProxy(java.lang.String sslProxy)
Specify which proxy to use for SSL connections.- Parameters:
sslProxy
- the proxy host, expected format ishostname.com:1234
- Returns:
- reference to self
-
getSocksProxy
public java.lang.String getSocksProxy()
Gets the SOCKS proxy.- Returns:
- the SOCKS proxy if present, null otherwise
-
setSocksProxy
public Proxy setSocksProxy(java.lang.String socksProxy)
Specifies which proxy to use for SOCKS.- Parameters:
socksProxy
- the proxy host, expected format ishostname.com:1234
- Returns:
- reference to self
-
getSocksVersion
public java.lang.Integer getSocksVersion()
Gets the SOCKS version (4 or 5).- Returns:
- the SOCKS version if present, null otherwise
-
setSocksVersion
public Proxy setSocksVersion(java.lang.Integer socksVersion)
Specifies which version of SOCKS to use (4 or 5).- Parameters:
socksVersion
- SOCKS version, 4 or 5- Returns:
- reference to self
-
getSocksUsername
public java.lang.String getSocksUsername()
Gets the SOCKS proxy's username. Supported by SOCKS v5 and above.- Returns:
- the SOCKS proxy's username
-
setSocksUsername
public Proxy setSocksUsername(java.lang.String username)
Specifies a username for the SOCKS proxy. Supported by SOCKS v5 and above.- Parameters:
username
- username for the SOCKS proxy- Returns:
- reference to self
-
getSocksPassword
public java.lang.String getSocksPassword()
Gets the SOCKS proxy's password. Supported by SOCKS v5 and above.- Returns:
- the SOCKS proxy's password
-
setSocksPassword
public Proxy setSocksPassword(java.lang.String password)
Specifies a password for the SOCKS proxy. Supported by SOCKS v5 and above.- Parameters:
password
- password for the SOCKS proxy- Returns:
- reference to self
-
getProxyAutoconfigUrl
public java.lang.String getProxyAutoconfigUrl()
Gets the proxy auto-configuration URL.- Returns:
- the proxy auto-configuration URL
-
setProxyAutoconfigUrl
public Proxy setProxyAutoconfigUrl(java.lang.String proxyAutoconfigUrl)
Specifies the URL to be used for proxy auto-configuration. Expected format ishttp://hostname.com:1234/pacfile
. This is required ifgetProxyType()
is set toProxy.ProxyType.PAC
, ignored otherwise.- Parameters:
proxyAutoconfigUrl
- the URL for proxy auto-configuration- Returns:
- reference to self
-
extractFrom
public static Proxy extractFrom(Capabilities capabilities)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-