How to work with Proxy in Selenium WebDriver

In this article we are going to see the functions for the configuration of proxy while testing a web application(under different proxy) . The are various property to control proxy settings of a browser. In here I am using c# with VS 2010.

Selenium webdriver has build-in class to maintain proxy settings.  We have to initialize a proxy object.We can initialize in 2 ways.

private Proxy myProxy = new Proxy();

Another one with proxy settings string as dictionary(multiple settings initialization) .
new Proxy(Dictionary settings)

A proxy object has seven properties . These properties are used for several purposes.

-To Get or set the value(string) of the proxy for the FTP protocol.

-To Get or set the value(string) of the proxy for the HTTP protocol.

-To Get or set a value(Boolean) to know proxy uses autodetection.

-To Gets or sets the value(string) for when no proxy is specified.It will overwrite the proxy settings.

-To Get or set the URL(as string) used for proxy Auto Configuration. 

 -To Get or set the value(string) of the proxy for the SSL protocol.

-To Get or set the type of proxy(enum).
mProxyKind = myProxy.Kind;

Note : There is an Enum(ProxyKind) for identifying the proxy type.
The ProxyKind enum members are :

Member name
Value Description
Direct 0
Direct connection, no proxy (default on Windows).
Manual 1
Manual proxy settings (e.g., for httpProxy).
ProxyAutoConfigure 2
Proxy autoconfiguration from URL.
AutoDetect 4
Use proxy autodetection.
System 5
Use the system values for proxy settings (default on Linux).
Unspecified 6
No proxy type is specified.

In here, These are property functionality of a proxy object. I will provide example with proxy configuration in separate post where we can see different configurations for different proxy(like NTLM, CC proxy, Win Gate etc).


No comments:

Post a Comment