DriverCreationException with BrowserStackDriverFactory behind Proxy

515 views
Skip to first unread message

Alexander Kriegisch

unread,
Jan 29, 2016, 4:55:25 AM1/29/16
to Geb User Mailing List
Hello.

We use Geb 0.12.2 and Spock 0.7 with Groovy 2.4.1.

We are behind an authenticating web proxy and I cannot connect to BrowserStack because I receive an error message (access denied, not authenticated) from our web proxy even though I have something like this in GebConfig:

System.properties.put("http.proxyHost", "proxy.xxx.de");
System.properties.put("http.proxyPort", "3128");
System.properties.put("http.proxyUser", "myuser");
System.properties.put("http.proxyPassword", "mypw");
System.properties.put("https.proxyHost", "proxy.xxx.de");
System.properties.put("https.proxyPort", "3128");
System.properties.put("https.proxyUser", "myuser");
System.properties.put("https.proxyPassword", "mypw");

The error message is as follows:

geb.driver.DriverCreationException: failed to create driver from callback 'script1454059893262814155511$_run_closure3$_closure4$_closure5@6f70f32f'

at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:85)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy)
at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:32)
at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:84)
at geb.Configuration.createDriver(Configuration.groovy:382)
at geb.Configuration.getDriver(Configuration.groovy:371)
at geb.Browser.getDriver(Browser.groovy:109)
at geb.Browser.go(Browser.groovy:499)
at geb.Browser.go(Browser.groovy:489)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:56)
at de.sdvrz.okv.customer.geb.DummyGebTest.testSomething(DummyGebTest.groovy:94)
Caused by: java.lang.reflect.InvocationTargetException
at geb.driver.CloudDriverFactory.create(CloudDriverFactory.groovy:55)
at script1454059893262814155511$_run_closure3.closure4$_closure5(script1454059893262814155511.groovy:152)
at script1454059893262814155511$_run_closure3.closure4$_closure5(script1454059893262814155511.groovy)
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
... 11 more
Caused by: org.openqa.selenium.UnsupportedCommandException: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" 
(the rest of the web proxy error message follows)


Marcin Erdmann

unread,
Jan 30, 2016, 11:03:24 AM1/30/16
to Geb User Mailing List
This is more a WebDriver question than a Geb question, but a quick google reveals that you need to set the proxy via desired capabilities:

Proxy proxy = new Proxy();
proxy.setHttpProxy(proxyHost + ":" + proxyPort);

And then:

new BrowserStackDriverFactory().create(browserStackBrowser, username, accessKey, localId, [(CapabilityType.PROXY): proxy])

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/d093eede-af3f-4794-b5b9-76bd15539d30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexander Kriegisch

unread,
Feb 1, 2016, 4:31:35 AM2/1/16
to Geb User Mailing List
Sorry Marcin,

but your answer does not sound reasonable to me. As my error log shows, I already get an error message by our web proxy which is about authentication. Your code snippet also just shows how to set a proxy host and port, but not how to authenticate against the proxy. And BTW, the way I set proxy settings via system properties was taken straight from the BrowserStack manual.

I know how to google and could not find anything about a canonical way to use proxy authentication via Selenium or Geb. So I figured that because I cannot be the first one in this situation, someone here on the list might know more than I.

I would be glad to receive further instructions. Thank you so much.

Regards

Marcin Erdmann

unread,
Feb 1, 2016, 4:48:42 PM2/1/16
to Geb User Mailing List
Hi Alexander,

Sorry to hear that my answer sounds unreasonable to you. I mentioned googling not to imply that you didn't do it but to admit that I did and that's all the knowledge about using a proxy with WebDriver I have as I never had to do it myself. And your question clearly mentioned that it's about the credentials not being picked up and not the about proxy not being used at all.

All that I found is this stackoverflow thread: http://stackoverflow.com/questions/34846014/using-selenium-remotewebdriver-behind-corporate-proxy/34908953#34908953. The answer seems very complex, one would expect this to be easier due to using an authenticated proxy being a relatively common thing to do. On the other hand RemoteWebDriver is using Apche's HttpClient which means that to get it working you will have to configure the client used to use an authenticated proxy. Using a custom HttpClient factory will not play nicely with BrowserStackDriverFactory a it was not designed with such requirement in mind so you will be on your own in this regard. Sorry that I cannot help any more but I have no experience in using an authenticated proxy with RemoteWebDriver.

Marcin

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
Message has been deleted

Chris Byrneham

unread,
Feb 2, 2016, 8:28:29 AM2/2/16
to Geb User Mailing List
Hi, I'm trying to get browserstack to work on windows behind a corporate proxy as well.
 I've tried running the BrowserStackLocal.exe and have to add the -proxyHost -proxyPort -proxyUser -proxyPass 
 when it then connects. 
 
 When I try to run geb tests I noticed it uses the 
 
 geb.gradle.browserstack.BrowserStackTunnel class in the integration\geb-gradle module.
 
 The BrowserStackTunnel class downloads and unzips the tunnel exe.
 Builds a command line, and then runs it with parameters it gets from the BrowserStackExtension class.
 
 The problem is that the command line for the tunnel has no facility to include any of the proxy parameters
 and the BrowserStackExtension has no proxyHost proxyPort proxyUser proxyPass properties.

 I propose adding the extra params to the BrowserStackExtension, and refactoring BrowserStackTunnel to build 
 the tunnel command line with them if they are present.
 
 An alternative would be to pick them up from the JVM or Gradle system properties ?
 
 I'm currently trying to build a local copy of geb from source so I can try out the changes.
- show quoted text -

Brian Kotek

unread,
Feb 2, 2016, 10:09:15 AM2/2/16
to Geb User Mailing List
I'm sure Marcin would be happy to consider a pull request if you can get it working. Have you tried getting things working in a simple, non-Geb project, just to confirm exactly what needs to happen for the proxy to be configured properly?

On Tue, Feb 2, 2016 at 7:26 AM, Chris Byrneham <chr...@motabilityoperations.co.uk> wrote:

Hi, I'm trying to get browserstack to work on windows behind a corporate proxy as well.
 I've tried running the BrowserStackLocal.exe and have to add the -proxyHost -proxyPort -proxyUser -proxyPass 
 when it then connects. 
 
 When I try to run geb tests I noticed it uses the 
 
 geb.gradle.browserstack.BrowserStackTunnel class in the integration\geb-gradle module.
 
 The BrowserStackTunnel class downloads and unzips the tunnel exe.
 Builds a command line, and then runs it with parameters it gets from the BrowserStackExtension class.
 
 The problem is that the command line for the tunnel has no facility to include any of the proxy parameters
 and the BrowserStackExtension has no proxyHost proxyPort proxyUser proxyPass properties.

 I propose adding the extra params to the BrowserStackExtension, and refactoring BrowserStackTunnel to build 
 the tunnel command line with them if they are present.
 
 An alternative would be to pick them up from the JVM or Gradle system properties ?
 
 I'm currently trying to build a local copy of gradle from source so I can try out the changes.




On Friday, January 29, 2016 at 9:55:25 AM UTC, Alexander Kriegisch wrote:

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.

Alexander Kriegisch

unread,
Feb 8, 2016, 7:01:16 AM2/8/16
to Geb User Mailing List
Somehow this did not work, but I could persuade our admin to permit me passing through the proxy to SauceLabs and BrowserStack without authentication. So the problem was rather worked around than fixed.

Marcin Erdmann

unread,
Feb 10, 2016, 3:09:14 AM2/10/16
to geb-...@googlegroups.com
Good to hear that you found a solution, Alexander, even though it might not seem perfect.
--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/73a84b1e-8dcc-4a20-84e6-3044b6322f75%40googlegroups.com.

Marcin Erdmann

unread,
Feb 10, 2016, 3:12:32 AM2/10/16
to geb-...@googlegroups.com
Brian,

Chris seemed to follow your advice wrt a pull request and submitted one. I will attend to it this week. Hopefully I will be happy to merge it and it should be available to everybody soon as I'm planning to push a release in the comming days.

Marcin

pavan reddy

unread,
Feb 10, 2016, 6:00:06 AM2/10/16
to Geb User Mailing List

Hi you can try in cmd set http_proxy=http://username:password@your_proxy:your_port

or create a bat file with above code and run it before test

Regards
Pavan
Reply all
Reply to author
Forward
0 new messages