Class Proxy
java.lang.Object
org.openqa.selenium.Proxy
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.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic @Nullable ProxyextractFrom(Capabilities capabilities) @Nullable StringGets the HTTP proxy.@Nullable StringGets proxy bypass (noproxy) addresses.@Nullable StringGets the proxy auto-configuration URL.Gets theProxy.ProxyType.@Nullable StringGets the SOCKS proxy's password.@Nullable StringGets the SOCKS proxy.@Nullable StringGets the SOCKS proxy's username.@Nullable IntegerGets the SOCKS version (4 or 5).@Nullable StringGets the SSL tunnel proxy.inthashCode()booleanWhether to autodetect proxy settings.setAutodetect(boolean autodetect) Specifies whether to autodetect proxy settings.setHttpProxy(String httpProxy) Specify which proxy to use for HTTP connections.setNoProxy(String noProxy) Sets proxy bypass (noproxy) addressessetProxyAutoconfigUrl(String proxyAutoconfigUrl) Specifies the URL to be used for proxy auto-configuration.setProxyType(Proxy.ProxyType proxyType) Explicitly sets the proxy type, useful for forcing direct connection on Linux.setSocksPassword(String password) Specifies a password for the SOCKS proxy.setSocksProxy(String socksProxy) Specifies which proxy to use for SOCKS.setSocksUsername(String username) Specifies a username for the SOCKS proxy.setSocksVersion(Integer socksVersion) Specifies which version of SOCKS to use (4 or 5).setSslProxy(String sslProxy) Specify which proxy to use for SSL connections.toJson()toString()
-
Constructor Details
-
Proxy
public Proxy() -
Proxy
-
-
Method Details
-
toJson
-
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
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
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
-
getHttpProxy
Gets the HTTP proxy.- Returns:
- the HTTP proxy hostname if present, or null if not set
-
setHttpProxy
-
getNoProxy
Gets proxy bypass (noproxy) addresses.- Returns:
- The proxy bypass (noproxy) addresses
-
setNoProxy
-
getSslProxy
Gets the SSL tunnel proxy.- Returns:
- the SSL tunnel proxy hostname if present, null otherwise
-
setSslProxy
-
getSocksProxy
Gets the SOCKS proxy.- Returns:
- the SOCKS proxy if present, null otherwise
-
setSocksProxy
-
getSocksVersion
Gets the SOCKS version (4 or 5).- Returns:
- the SOCKS version if present, null otherwise
-
setSocksVersion
-
getSocksUsername
Gets the SOCKS proxy's username. Supported by SOCKS v5 and above.- Returns:
- the SOCKS proxy's username
-
setSocksUsername
-
getSocksPassword
Gets the SOCKS proxy's password. Supported by SOCKS v5 and above.- Returns:
- the SOCKS proxy's password
-
setSocksPassword
-
getProxyAutoconfigUrl
Gets the proxy auto-configuration URL.- Returns:
- the proxy auto-configuration URL
-
setProxyAutoconfigUrl
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
-
toString
-
equals
-
hashCode
-