Help to set no proxy for InternetExplorerDriver

3,890 views
Skip to first unread message

salinh

unread,
Aug 13, 2013, 2:58:39 PM8/13/13
to seleniu...@googlegroups.com
Hi all,

My IE Browser was set proxy before. I want to set direct connection (no proxy) when initializing a new InternetExplorerDriver instance in run time. I can do it with FirefoxProfile but not with DesiredCapabilities. The code below just set specified proxy but not set no proxy. 
Could you please help me to set no proxy for InternetExplorerDriver?


String PROXY = "localhost:8080";

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
     .setFtpProxy(PROXY)
     .setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new InternetExplorerDriver(cap);

I would have something like that:

Proxy proxy = Proxy.NO_Proxy; DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new InternetExplorerDriver(cap);


Selenium version: 2.33 OS: Win 7 64 bit Browser: IE Browser version: 8,9 Thanks in advance.

Krishnan Mahadevan

unread,
Aug 13, 2013, 11:33:56 PM8/13/13
to Selenium Users
I would be interested in this too. I haven't found a way in which I could instruct IE to always open up with a No Proxy (or) Use system proxy settings when a new WebDriver instance is created [ maybe driven by a flag which will let me override whatever was the previous values ]

We have been having the need to perform security scans and we route our automation tests to go via an IBM AppScan Server by putting it up as a proxy.
But what we have found that once we set this to IE, it kind of gets stuck to the IE settings and there is no direct way (atleast something that I can think of) which would let me undo this.

Jim, would you be able to help advise on this ?





Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/3bc60fee-00f8-40e0-ab2b-e59dc0137286%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Yeshwant Murali

unread,
Aug 14, 2013, 12:37:28 AM8/14/13
to seleniu...@googlegroups.com
I too would be interested if a workaround was available for this issue. Since last week, we have been struggling with an issue, where webdriver fails to launch the IE/FF/Chrome browser.
Till recently, the users were on a specific domain (XYZ) and were migrated to a newer one (ABC). The scripts were executing without any issues when invoked from XYZ\User1 credentials. But scripts fail to execute when launched from ABC\User1 credentials.
 
I tried googling and found some solutions listed;
- Setting same Protection level for all - Internet/Intranet/Trusted etc
- Setting Browser Zoom level to 100%
- Setting Proxy v/s No Proxy
- Setting UAC level to 0
 
Nothing seems working. I guess there must be some group policy introduced by IT Team, which is restricting the execution. Upon further troubleshooting efforts from my fellow colleagues, this was noted - '

(Error details: Unable to bind to port NNNN; timeout after 45000 milliseconds)

 

I was also unable to set the Protection Mode to Disabled mode at run time. When executed, I just the command window with message - 'Listening to port NNNN'...... But does not invoke the browser.
 
Selenium version: 2.33 / 2.35 / 2.28 with C# - Visual Studio 2012 Express edition

OS: Win 7 64 bit
Browser: IE / FF
Browser version: 8,9 / 21
 
Any workarounds?

Thank you,
Yeshwant
 

Alexandr Savchuk

unread,
Aug 14, 2013, 4:50:28 AM8/14/13
to seleniu...@googlegroups.com
To all:

1. Selenium 2.35 intoduced the following capabilities:
* ie.setProxyByServer
* ie.usePerProcessProxy

By setting these to True selenium will use IEDriverServer for setting IE proxy settings but not old java code which uses Windows Registry (and this java code has known issue - IE proxy settings turned off only when java process stopped).
Event more - the second capability allows to set IE proxy setting only for single instance so another instances will not use this settings.

Old way (Windows registry) is still supported but marked as deprecated and will be turn off in next releases.

2. Proxy type can be SYSTEM - it means that default IE settings will be used and none will be set by IEDriverServer.

3. NO_PROXY (proxy bypass) as i can see is not supported yet (and not supported by old java code).
Please raise new issue.

P.S.: Yeshwant Murali, looks like another issue - nothing related to proxy is in your comment.

вторник, 13 августа 2013 г., 22:58:39 UTC+4 пользователь salinh написал:

Krishnan Mahadevan

unread,
Aug 14, 2013, 5:50:54 AM8/14/13
to Selenium Users
Alex,
Thank you so much. I was going through the change logs and noticed this.

Does the below code represent the correct way of setting this capability ?

        DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
        dc.setCapability("ie.usePerProcessProxy", true);
        dc.setCapability("ie.usePerProcessProxy", true);
        dc.setCapability("ie.setProxyByServer", true);
        Proxy p = new Proxy();
// set the proxy information 
        dc.setCapability(CapabilityType.PROXY, p);
        RemoteWebDriver rwd = new RemoteWebDriver(new URL(url),dc);




Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

Alexandr Savchuk

unread,
Aug 14, 2013, 8:17:26 AM8/14/13
to seleniu...@googlegroups.com
Yes, look good.

среда, 14 августа 2013 г., 13:50:54 UTC+4 пользователь Krishnan написал:

Jim Evans

unread,
Aug 14, 2013, 8:50:40 AM8/14/13
to seleniu...@googlegroups.com
This looks correct. However, there are some caveats you need to be aware of regarding these new capabilities. For ie.setProxyByServer, this capability is *only* understood by the Java language bindings (and by extension, the Java remote Selenium server). If you are using another language binding (Python, Ruby, .NET, or anything else), and you are talking directly to IEDriverServer.exe (not going through a Java remote Selenium server), this capability has no effect. In the case of other language bindings using IEDriverServer.exe directly, setting a proxy via capabilities will all be handled using the code internal to IEDriverServer.exe.
 
Also note that the behavior of the Java proxy setting code and the IEDriverServer.exe proxy setting code is *vastly* different. The Java proxy code (incorrectly, IMHO) does far more than just set proxy settings. The IEDriverServer code is much more conservative, and uses the "correct" (according to Microsoft) APIs for setting the proxy, rather than attempting to hack the registry.
 
For ie.usePerProcessProxy, this is an invalid setting for proxies of type "autodetect" or "pac" (proxy autoconfigure)[1]. Proxies of type "system", "direct", or "manual" will still work.
 
--Jim
 

Anton

unread,
Aug 14, 2013, 9:39:40 AM8/14/13
to seleniu...@googlegroups.com
Can you not start up server with -avoidProxy parameter.

Not sure if this available on IEserver or something we have in my company but it allows us to get past the proxy.

Cheers

Anthony

Jim Evans

unread,
Aug 14, 2013, 9:59:52 AM8/14/13
to seleniu...@googlegroups.com
I can categorically state that there is no such command line switch for IEDriverServer.exe. The Java remote server might support that command line switch; I don't know, but I've never heard of it. By far, the best way to set up the proxy for the browser in WebDriver is to use the proxy capability.

Yeshwant Murali

unread,
Aug 14, 2013, 11:29:15 AM8/14/13
to seleniu...@googlegroups.com
May be...Alex. Looking to see if there are any solutions. Issue is still not resolved.

Thank you,
Yeshwant


On Wed, Aug 14, 2013 at 2:20 PM, Alexandr Savchuk <a.u.s...@gmail.com> wrote:

Lesley Brown

unread,
Sep 12, 2013, 6:58:33 PM9/12/13
to seleniu...@googlegroups.com
Hi,

It is pretty wild that a residual proxy is used and not reset if no proxy is specified.  Seems like a sloppy approach...  I would expect the opposite for default behavior. 
Anyways, regardless of the reason or whatever, here is a method I use to reset the proxy to no proxy (unless I specify the proxy to use as a parameter).  This seems to work okay for IE and FF but not Chrome so the workaround for Chrome is to specify a pass through proxy (which I can override with a property).
Note that this example uses Apache StringUtils to catch cases of null or empty string.  Also that Browser is just an enum for the browser type.
I hope this helps!

private static void proxySet ( final Browser browser, DesiredCapabilities desCaps, final String proxyServer ) {


        Proxy py = new Proxy();

        if ( StringUtils.isNotBlank( proxyServer ) ) {

            // Use the specified proxy.

            py.setHttpProxy( proxyServer );

            py.setFtpProxy ( proxyServer );

            py.setSslProxy ( proxyServer );

            py.setNoProxy("");

        } else {

           

            // Workaround for Chrome as it does not seem to support setting the proxy to DIRECT so use a pass through proxy for now.

            if ( browser == Browser.CHROME ) {

                String proxyToUse = System.getProperty("default.proxy", "80.80.80.80:8080");

                py.setHttpProxy( proxyToUse );

                py.setFtpProxy ( proxyToUse );

                py.setSslProxy ( proxyToUse );

                py.setNoProxy("");

            } else {

                // Do not use a proxy.

                py.setNoProxy( "DIRECT" );

                desCaps.setCapability( CapabilityType.ForSeleniumServer.AVOIDING_PROXY, true );

                desCaps.setCapability( CapabilityType.ForSeleniumServer.ONLY_PROXYING_SELENIUM_TRAFFIC, true );

                desCaps.setCapability( CapabilityType.ForSeleniumServer.PROXYING_EVERYTHING, false );

            }

        }

        Log.info ( "setting http proxy(" + py.getHttpProxy() + ")" );

        desCaps.setCapability("ie.usePerProcessProxy", true);

        desCaps.setCapability("ie.setProxyByServer", true);

        desCaps.setCapability ( CapabilityType.PROXY, py );

Антон Свидерский

unread,
Apr 28, 2017, 1:04:49 PM4/28/17
to Selenium Users
Hi Lesley!

Nice to have this question finally answered. I was trying to configure proxy the same way for all the browsers in test. While Firexfox and Chrome could go through my custom proxy server, IE would ignore them. Thank you!

пятница, 13 сентября 2013 г., 1:58:33 UTC+3 пользователь Lesley Brown написал:
Reply all
Reply to author
Forward
0 new messages