Having difficulty using SauceLabs with Gradle

155 views
Skip to first unread message

Ben Frey

unread,
Oct 22, 2019, 1:33:38 PM10/22/19
to Geb User Mailing List
My tests are working locally, although I have to use the bonigarcia WebDriverManager to retrieve a Chromedriver locally:
WebDriverManager.chromedriver().version('2.35').setup()

In my build.gradle file I want to set up an Internet Explorer browser in the remote SauceLabs instance:
sauceLabs {
    browsers
{
        create
('internet explorer') {
            capabilities platform
: 'Windows 7', browserVersion: '11'
       
}
        task
{
       
}
        account
{
           
def username = System.getenv('SAUCE_USERNAME')
           
def accessKey = System.getenv('SAUCE_ACCESS_KEY')
       
}
   
}
}

and my GebConfig.groovy looks like this
baseUrl = 'https://www.domain.com'
reportsDir
= 'build/reports/tests/geb'

def sauceLabsBrowser = System.getProperty('geb.saucelabs.browser')
if (sauceLabsBrowser) {
    println
'Got a SauceLabs browser'
    driver
= {
       
def username = System.getenv('SAUCE_USERNAME')
       
assert username
       
def saucelabsKey = System.getenv('SAUCE_ACCESS_KEY')
       
assert  saucelabsKey

       
new SauceLabsDriverFactory().create(sauceLabsBrowser, username, saucelabsKey)
   
}
} else {
    println
'Attempting to get a local webdriver'
   
// WebDriverManager.chromedriver().version('2.35').setup()
}

When I push my code to my company's GitLab instance, I get the following stack trace:
tests.TestClass > classMethod FAILED
    java
.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
        at com
.google.common.base.Preconditions.checkState(Preconditions.java:847)
        at org
.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:134)
        at org
.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35)
        at org
.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159)
        at org
.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355)
        at org
.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94)
        at org
.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
        at geb
.driver.NameBasedDriverFactory.getDriver(NameBasedDriverFactory.groovy:44)
        at geb
.driver.CachingDriverFactory.getDriver_closure4(CachingDriverFactory.groovy:57)
        at geb
.driver.CachingDriverFactory.getDriver_closure4(CachingDriverFactory.groovy)
        at geb
.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:81)
        at geb
.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:56)
        at geb
.Configuration.createDriver(Configuration.groovy:675)
        at geb
.Configuration.getDriver(Configuration.groovy:353)
        at geb
.Browser.getDriver(Browser.groovy:160)
        at geb
.navigator.factory.BrowserBackedNavigatorFactory.<init>(BrowserBackedNavigatorFactory.groovy:31)
        at geb
.Configuration.createNavigatorFactory(Configuration.groovy:413)
        at geb
.Browser.createNavigatorFactory(Browser.groovy:982)
        at geb
.Browser.getNavigatorFactory(Browser.groovy:170)
        at geb
.Page.init(Page.groovy:140)
        at geb
.Browser.initialisePage(Browser.groovy:1116)
        at geb
.Browser.createPage(Browser.groovy:829)
        at geb
.Browser.to(Browser.groovy:537)
        at geb
.Browser.to(Browser.groovy:526)
        at geb
.spock.GebSpec.methodMissing(GebSpec.groovy:60)
        at login
.LoginTrait$Trait$Helper.logIn(LoginTrait.groovy:7)
        at tests
.TestClass.setupSpec(TestClass.groovy:8)

So I have two questions:
  1. Why is it trying to retrieve a Chrome webdriver in the CI pipeline when my buildscript specifies Internet Explorer?
  2. Am I setting everything up as expected? I left out the sauceLabs.task closure because I was getting Gradle errors on e.g. test.testClassesDir

Marcin Erdmann

unread,
Oct 23, 2019, 7:27:12 AM10/23/19
to geb-...@googlegroups.com
What's the Gradle task that you are running in CI?

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/7545c8f8-e510-4065-8d3c-7c29b67304b0%40googlegroups.com.

Ben Frey

unread,
Oct 23, 2019, 8:28:50 AM10/23/19
to Geb User Mailing List
./gradlew clean testTaskName

where "testTaskName" is a Gradle task defined like this
task testTaskName(type: Test) {
    filter
{
        includeTestsMatching
'stufftotest.*'
   
}
}

To unsubscribe from this group and stop receiving emails from it, send an email to geb-...@googlegroups.com.

Marcin Erdmann

unread,
Oct 23, 2019, 8:55:08 AM10/23/19
to geb-...@googlegroups.com
Yeah, this is where the problem is. The Gradle SauceLabs plugin adds a separate task to run tests at SauceLabs - any tasks that you add manually as well as the default test task will not include the configuration for  SauceLabs. Based on the configuration that you provided in the original email the test task name will be internetExplorerTest - it's derived on the name of the item that you add in the `browsers {}` configuration block. It's all described at https://gebish.org/manual/current/#geb-saucelabs-plugin.

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/b70f3fe1-acd7-4317-8df6-c74f91d77270%40googlegroups.com.

Ben Frey

unread,
Oct 23, 2019, 8:59:06 AM10/23/19
to Geb User Mailing List
Oh, I guess I didn't quite get the implications of bullet point 4 there, thanks for clarifying. So is there a way to filter or group tests based on test class/method rather than capability? I'm trying to run groups of scenarios in parallel CI jobs, rather than all of the tests in one.

Marcin Erdmann

unread,
Oct 23, 2019, 9:09:53 AM10/23/19
to geb-...@googlegroups.com
No, unfortunately that's not supported at the moment. We would need to add support for adding multiple test tasks per capability/browser type - would you mind submitting an issue for that in the tracker? There's already a number of issues around improvements to cloud browser plugins, I could just make the next release all about that.

With regards to a workaround for this, there's nothing that comes to my mind apart from a nasty hack where you would set a project property on the command line, like -PstuffToTest=a and then have an if statement like:

sauceLabs {
        task {
            if (stuffToTest == "a") {
                filter {
                    includeTestsMatching 'stufftotest.*'
                }
            }
        }
    }
}

Nasty, but can work in the meantime.

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/21fa1c21-3185-4a12-ab6e-cebc799bf5c1%40googlegroups.com.

Ben Frey

unread,
Oct 23, 2019, 1:26:57 PM10/23/19
to Geb User Mailing List
Alright, I created https://github.com/geb/issues/issues/597. Please let me know if you'd like any more details in the issue.

Ben Frey

unread,
Oct 23, 2019, 2:08:59 PM10/23/19
to Geb User Mailing List
I now have a new problem (let me know if I should start a new thread). Gradle cannot set the property "username":
Caused by: groovy.lang.MissingPropertyException: Could not set unknown property 'username' for object of type geb.gradle.cloud.BrowserSpec.

This is happening right where the variable username is being set, just like in the example:
account {
    username
= System.getenv(SauceAccount.USER_ENV_VAR)
    accessKey
= System.getenv(SauceAccount.ACCESS_KEY_ENV_VAR)
}

My GebConfig.groovy file has this for the driver setup:
def sauceLabsBrowser = System.getProperty('geb.saucelabs.browser')
if (sauceLabsBrowser) {

    driver
= {
       
def username = System.getenv("GEB_SAUCE_LABS_USER")
       
assert username
       
def accessKey = System.getenv("GEB_SAUCE_LABS_ACCESS_PASSWORD")
       
assert accessKey

       
new SauceLabsDriverFactory().create(sauceLabsBrowser, username, accessKey)
   
}
} else {
   
System.setProperty('webdriver.chrome.driver', 'src/test/resources/chromedriver')
    driver
= { new ChromeDriver() }
}

What step am I missing?

John Anderson

unread,
Oct 23, 2019, 3:44:43 PM10/23/19
to geb-...@googlegroups.com
Are you sure you have the account block in the right place? You have it configured inside the browser block and in the documentation its declared only in the sauceLabs block.

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/ea68213d-cd16-4fce-b750-626dc9413020%40googlegroups.com.

Ben Frey

unread,
Oct 23, 2019, 3:59:19 PM10/23/19
to Geb User Mailing List
:facepalm: That did it. Thank you both for all the help!

Marcin Erdmann

unread,
Oct 23, 2019, 4:56:49 PM10/23/19
to geb-...@googlegroups.com
The issue you created Ben looks good, thanks!

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/8ba12b87-571b-4e65-a317-35c2ee010c5a%40googlegroups.com.

Ben Frey

unread,
Oct 24, 2019, 3:21:11 PM10/24/19
to Geb User Mailing List
It seems I'm still missing something; I'm getting an error message from Selenium code that my SauceLabs credentials are set to "None":
geb.driver.DriverCreationException: failed to create driver from callback 'script15719444756301696857021$_run_closure2@3a13610b'
    at geb
.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)

    at geb
.driver.CachingDriverFactory.getDriver_closure4(CachingDriverFactory.groovy:57)
    at geb
.driver.CachingDriverFactory.getDriver_closure4(CachingDriverFactory.groovy)
    at geb
.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:81)
    at geb
.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:56)
    at geb
.Configuration.createDriver(Configuration.groovy:675)
    at geb
.Configuration.getDriver(Configuration.groovy:353)
    at geb
.Browser.getDriver(Browser.groovy:160)
    at geb
.navigator.factory.BrowserBackedNavigatorFactory.<init>(BrowserBackedNavigatorFactory.groovy:31)
    at geb
.Configuration.createNavigatorFactory(Configuration.groovy:413)
    at geb
.Browser.createNavigatorFactory(Browser.groovy:982)
    at geb
.Browser.getNavigatorFactory(Browser.groovy:170)
    at geb
.Page.init(Page.groovy:140)
    at geb
.Browser.initialisePage(Browser.groovy:1116)
    at geb
.Browser.createPage(Browser.groovy:829)
    at geb
.Browser.to(Browser.groovy:537)
    at geb
.Browser.to(Browser.groovy:526)
    at geb
.spock.GebSpec.methodMissing(GebSpec.groovy:60)
    at login
.LoginTrait$Trait$Helper.logIn(LoginTrait.groovy:7)

    at testpackage
.TestClass.setupSpec(TestClass.groovy:8)

   
Caused by:
    java
.lang.reflect.InvocationTargetException
        at geb
.driver.CloudDriverFactory.create(CloudDriverFactory.groovy:51)
        at script15719444756301696857021
.run_closure2(script15719444756301696857021.groovy:30)
        at script15719444756301696857021
.run_closure2(script15719444756301696857021.groovy)
        at geb
.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
       
... 19 more

       
Caused by:
        org
.openqa.selenium.WebDriverException: Unable to parse remote response: Misconfigured -- Sauce Labs Authentication Error.
       
You used username 'None' and access key 'None' to authenticate, which are not valid Sauce Labs credentials.

My sauceLabs config is set like this:
sauceLabs {
    useTunnel
= false

    browsers
{
        create
('internet explorer') {
            capabilities platform
: 'Windows 7', browserVersion: '11'
       
}
   
}
    task
{

       
if (testSuite == 'specificTest') {
            filter
{
                includeTestsMatching
'testpackage.*'
           
}
       
}
   
}
    account
{
        username
= System.getenv(SauceAccount.USER_ENV_VAR)
        println
'In build.gradle, Sauce username is ' + username
        accessKey
= System.getenv(SauceAccount.ACCESS_KEY_ENV_VAR)
   
}
    connect
{
        additionalOptions
= ['--proxy', 'company.com:443/wd/hub']
   
}
}

In GebConfig.groovy I have exaclty the code from 14.1.1 in the BoG plus a println for the username. I see the username being printed out in both locations, so why is the Selenium code thinking the credentials aren't set?

Marcin Erdmann

unread,
Oct 25, 2019, 3:47:15 AM10/25/19
to geb-...@googlegroups.com
Can you please paste contents of your GebConfig.groovy? I trust what you are saying but without seeing it, we won't be able to spot any mistakes that you might have made. :)

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/10691e84-4368-4661-b9be-e374f0fbfd87%40googlegroups.com.

Ben Frey

unread,
Oct 25, 2019, 9:57:39 AM10/25/19
to Geb User Mailing List
Sure, here it is:
import geb.driver.SauceLabsDriverFactory
import org.openqa.selenium.Platform
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.remote.BrowserType

geb
.saucelabs.browser.browserName=BrowserType.IE
geb
.saucelabs.browser.platform=Platform.WINDOWS
geb
.saucelabs.browser.version=11

baseUrl
= 'https://company.com'
reportsDir
= 'build/reports/tests/geb'

waiting
{
    timeout
= 15
    retryInterval
= 0.5

}

def sauceLabsBrowser = System.getProperty('geb.saucelabs.browser')
if (sauceLabsBrowser) {

    driver
= {
       
def username = System.getenv("GEB_SAUCE_LABS_USER")
       
assert username
        println
'In config, Sauce username is ' + username
       
def accessKey = System.getenv("GEB_SAUCE_LABS_ACCESS_PASSWORD")

       
assert accessKey

       
new SauceLabsDriverFactory().create(sauceLabsBrowser, username, accessKey)
   
}
} else {
   
System.setProperty('webdriver.chrome.driver', 'src/test/resources/chromedriver')
    driver
= { new ChromeDriver() }
}

Marcin Erdmann

unread,
Oct 26, 2019, 5:23:22 PM10/26/19
to geb-...@googlegroups.com
Ok, so this looks all good to me. I don't see how you'd be passing anything other than what you see printed as credentials to SauceLabs. So the only things that come to mind are you are using wrong credentials (are you sure you're passing in an access key and not a password?) and SauceLabs is lying that you're passing "None" or you've hit this issue I was able to find: https://support.saucelabs.com/hc/en-us/articles/360000921754-Authentication-Error-with-Selenium-3-9-0-Java-Client-Bindings but it's unlikely you're using Selenium 3.9.0 as it's been around for quite some time.

I've also double checked that nothing has recently changed on the SauceLabs end and you can still pass creds as part of the URL (as SauceLabsDriverFactory does) and it has not because Geb's own tests at SauceLabs do not have any trouble with setting up the driver as of today: https://circleci.com/gh/geb/geb/2202.

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/041a1079-b908-4416-bac7-5ed9e306f090%40googlegroups.com.

Ben Frey

unread,
Oct 28, 2019, 9:12:45 AM10/28/19
to Geb User Mailing List
Interesting. Where would I find the version of Selenium I'm using? The only two Selenium dependencies I have in my build.gradle are
testCompile 'org.seleniumhq.selenium:selenium-chrome-driver:3.141.59'
testCompile
'org.seleniumhq.selenium:selenium-support:3.141.59'

So... I don't think I'm using 3.9.0, but even when printing out the full dependency tree I don't see anything that looks like a base Selenium library.

Ben Frey

unread,
Oct 28, 2019, 9:26:45 AM10/28/19
to Geb User Mailing List
I also found this in the job log; might be relevant? I don't know what "M" it's referring to:
org.openqa.selenium.json.JsonException: Unable to determine type from: M. Last 1 characters read: M
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'server', ip: '1.1.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-957.21.3.el7.x86_64', java.version: '1.8.0_212'


Ben Frey

unread,
Oct 28, 2019, 2:21:50 PM10/28/19
to Geb User Mailing List
For what it's worth, we have a set of WDIO tests that run in SauceLabs just fine. The config for those is
const sauceConf = {
    user
: process.env.SAUCE_USERNAME,
    key
: process.env.SAUCE_ACCESS_KEY,
    hostname
: 'test.company.com',
    path
: '/wd/hub',
    protocol
: 'https',
    port
: 443,
    specs
: [
       
'./tests/business-controls/*/*.js'
   
],
    maxInstances
: 14,
    capabilities
: [
       
{
            maxInstances
: 5,
            browserName
: 'internet explorer',
            parentTunnel
: 'company',
            tunnelIdentifier
: 'company-tunnel',
       
}
   
],
    logLevel
: 'warn',
    waitforTimeout
: 10000,
    connectionRetryCount
: 5,
    services
: ['sauce']
};

I notice it's setting up a tunnel, but if I comment out useTunnel = false, I get this in the logs:
> Task :openSauceTunnelInBackground
Task ':openSauceTunnelInBackground' is not up-to-date because:
 
Task has not declared any outputs despite executing actions.


> Task :openSauceTunnelInBackground FAILED
:openSauceTunnelInBackground (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 3 mins 0.163 secs.
:closeSauceTunnel (Thread[Execution worker for ':' Thread 4,5,main]) started.

> Task :closeSauceTunnel
Task ':closeSauceTunnel' is not up-to-date because:
 
Task has not declared any outputs despite executing actions.
disconnecting tunnel
:closeSauceTunnel (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 0.003 secs.
FAILURE
: Build failed with an exception.

* What went wrong:
Execution failed for task ':openSauceTunnelInBackground'.
> Timeout waiting for tunnel to open

Marcin Erdmann

unread,
Oct 28, 2019, 4:39:15 PM10/28/19
to geb-...@googlegroups.com
Yeah, it does not look like you're using 3.9.0. With regards to your failure for opening the tunnel - I can't see your full setup so it's impossible for me to tell what's going on. 

How about setting up a minimum reproducible example and uploading that to github? It can be just the simplest of tests going to gebish.org and checking the page title. It should expect the creds the same way as in what you sent before - via env vars. I can then check it out locally and give it a try by providing credentials I know work - the ones I use for Geb's own tests. I'm fairly certain that it will allow us to spot the issue quickly.

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 view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/d728439c-e156-48b5-9dd9-c8dc8f05ece1%40googlegroups.com.

Ben Frey

unread,
Oct 28, 2019, 4:51:33 PM10/28/19
to Geb User Mailing List
Company-proprietary code and all, so I can't, unfortunately. Unless you can think of a way around that.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-...@googlegroups.com.

Marcin Erdmann

unread,
Oct 28, 2019, 5:01:41 PM10/28/19
to geb-...@googlegroups.com
That's why I suggested creating a simple, reproducible example using something that is completely independent from your project and company (the bit where I said to use gebish.org and checking the title at the home page). It will require you to start from scratch on a fresh project but by doing so you might find that starting simple will help you spot the mistake and if there is no mistake on your side and you still have the exact problem as in your other project then I will be able to take a look at it as it will be completely independent from your work project and something you will be able to share with me.

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/6bdcfc1d-ede4-48bb-ac64-12b6e656e1f0%40googlegroups.com.

Ben Frey

unread,
Oct 28, 2019, 5:05:14 PM10/28/19
to Geb User Mailing List
 Oh, I see. I'll start working on that tomorrow, I hope. Although I'm still not sure about the SauceLabs portion since it involves a tunnel that's hosted by my company. Is that something I can mock out or otherwise deal with?

Marcin Erdmann

unread,
Oct 28, 2019, 5:45:34 PM10/28/19
to geb-...@googlegroups.com
A tunnel (if you are talking about a Sauce Labs tunnel) will not be needed because we won't be accessing anything specific to your company - gebish.org is accessible on the public Internet. Unless you are talking about some proxy that you are using which might potentially be stripping out the credentials from the url... (which are added like this: https://github.com/geb/geb/blob/master/module/geb-core/src/main/groovy/geb/driver/SauceLabsDriverFactory.groovy#L28). If that's the case then it also seems possible to authenticate via browser capabilities (https://wiki.saucelabs.com/display/DOCS/Best+Practice%3A+Use+Environment+Variables+for+Authentication+Credentials and expand the full example). Maybe that will work in your setup... To try it out you'll need to change your config script from:

new SauceLabsDriverFactory().create(sauceLabsBrowser, username, accessKey)

to

new SauceLabsDriverFactory().create(sauceLabsBrowser, "", "", [username: username, accessKey: accessKey])


On Mon, Oct 28, 2019 at 9:05 PM Ben Frey <sparta...@gmail.com> wrote:
 Oh, I see. I'll start working on that tomorrow, I hope. Although I'm still not sure about the SauceLabs portion since it involves a tunnel that's hosted by my company. Is that something I can mock out or otherwise deal with?

--
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.

Ben Frey

unread,
Oct 29, 2019, 10:07:07 PM10/29/19
to Geb User Mailing List
Ok, I've got my minimum example: https://github.com/spartanhooah/geb-sauce-test

I did try the alternate method of creating the SauceLabsDriverFactory but that resulted in these messages:

sauce-connect: <timestamp> - Error in checkUpdate: couldn't connect to https://saucelabs.com/versions.json: Get https://saucelabs.com/versions.json: malformed HTTP response "\x15\x03\x03\x00\x02\x02"
sauce-connect: <timestamp> - started scproxy on port 37318.
sauce-connect: <timestamp> - Please wait for 'you may start your tests' to start your tests.
sauce-connect: <timestamp> - failed to check for existing tunnels
sauce-connect: <timestamp> - Sauce Connect could not establish a connection
sauce-connect: <timestamp> - Please check your firewall and proxy settings
The command-line arguments for sc were
--user <me> --api-key **** --se-port 4445 --proxy test.company.com:443



On Monday, October 28, 2019 at 9:45:34 PM UTC, Marcin Erdmann wrote:
A tunnel (if you are talking about a Sauce Labs tunnel) will not be needed because we won't be accessing anything specific to your company - gebish.org is accessible on the public Internet. Unless you are talking about some proxy that you are using which might potentially be stripping out the credentials from the url... (which are added like this: https://github.com/geb/geb/blob/master/module/geb-core/src/main/groovy/geb/driver/SauceLabsDriverFactory.groovy#L28). If that's the case then it also seems possible to authenticate via browser capabilities (https://wiki.saucelabs.com/display/DOCS/Best+Practice%3A+Use+Environment+Variables+for+Authentication+Credentials and expand the full example). Maybe that will work in your setup... To try it out you'll need to change your config script from:

new SauceLabsDriverFactory().create(sauceLabsBrowser, username, accessKey)

to

new SauceLabsDriverFactory().create(sauceLabsBrowser, "", "", [username: username, accessKey: accessKey])


On Mon, Oct 28, 2019 at 9:05 PM Ben Frey <sparta...@gmail.com> wrote:
 Oh, I see. I'll start working on that tomorrow, I hope. Although I'm still not sure about the SauceLabs portion since it involves a tunnel that's hosted by my company. Is that something I can mock out or otherwise deal with?

--
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-...@googlegroups.com.

Marcin Erdmann

unread,
Nov 1, 2019, 7:48:27 AM11/1/19
to geb-...@googlegroups.com
Hi Ben,

Thanks for providing the sample, it's very helpful. I checked it out and executed the following:

[erdi@mbp /tmp/geb-sauce-test (master *)]$ ./gradlew allSauceLabsTest --console plain
> Task :compileJava NO-SOURCE
> Task :compileGroovy NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE

> Task :unpackSauceConnect
[DEBUG] Expanding: /private/tmp/geb-sauce-test/build/sauce-connect/sc-4.5.4-osx.zip into /private/tmp/geb-sauce-test/build/sauce-connect
[DEBUG] expand complete

> Task :openSauceTunnelInBackground
> Task :compileTestJava NO-SOURCE
> Task :compileTestGroovy
> Task :processTestResources
> Task :testClasses
> Task :internetExplorerTest
> Task :internetExplorerDecorateReports
> Task :closeSauceTunnel
> Task :allSauceLabsTests

BUILD SUCCESSFUL in 43s
7 actionable tasks: 7 executed

This is the test run from sauce labs: https://app.saucelabs.com/tests/d85c832db0a349f882a93476e9920e40

I then changed this line in GebConfig:

new SauceLabsDriverFactory().create(sauceLabsBrowser, username, accessKey)

to 

new SauceLabsDriverFactory().create(sauceLabsBrowser, "", "", [username: username, accessKey: accessKey])

And also got a success.

All of this suggests to me that the problem is not in Geb or your code but it's in the environment in which you are running the tests. Something is clearly interfering with the requests that you are sending to SauceLabs.

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/d8e0dc21-c067-45c1-8a11-a0986fdfe475%40googlegroups.com.

Ben Frey

unread,
Nov 1, 2019, 8:47:48 AM11/1/19
to Geb User Mailing List
That's what I was afraid of. I've opened a ticket with our development support folks and hopefully I'll be able to talk to someone at SauceLabs as well. I tried adding in the configurations that are in the WDIO version of the project (namely parentTunnel and tunnelIdentifier):
capabilities: [
   
{
        maxInstances
: 5,
        browserName
: 'internet explorer',

        parentTunnel
: 'company_admin',
        tunnelIdentifier
: 'company-ha-tunnel',
   
}
],
 so my browsers block looks like this:
browsers {
    create
('internet explorer') {

        capabilities
(
                browserName
: 'Internet Explorer',
                platform
: 'Windows 7',
                version
: '11',
                parentTunnel
: 'company_admin',
                tunnelIdentifier
: 'company-ha-tunnel'
       
)
   
}
}
but that didn't seem to help.

Ben Frey

unread,
Nov 1, 2019, 9:10:45 PM11/1/19
to Geb User Mailing List
Alright, I think I've made a little progress. We passed the proxy URL to the SauceLabsDriverFactory like this:
new SauceLabsDriverFactory('testserver.company.com:443/wd/hub')
and now we're having a different stack trace - it seems the tunnel is created successfully (I see "Sauce Connect is up, you may start your tests."), but somehow the test can't connect to the proxy. After "Unexpected status line:" in the exception message there are five numbers in boxes that I can only see in BeyondCompare. The full stack trace is below. Do you have any ideas what's going on?
test.TestClass > classMethod FAILED
    geb
.driver.DriverCreationException: failed to create driver from callback 'script15726565316811155837962$_run_closure2@65de3495'

        at geb
.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
        at geb
.driver.CachingDriverFactory.getDriver_closure4(CachingDriverFactory.groovy:57)
        at geb
.driver.CachingDriverFactory.getDriver_closure4(CachingDriverFactory.groovy)
        at geb
.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:81)
        at geb
.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:56)
        at geb
.Configuration.createDriver(Configuration.groovy:675)
        at geb
.Configuration.getDriver(Configuration.groovy:353)
        at geb
.Browser.getDriver(Browser.groovy:160)
        at geb
.navigator.factory.BrowserBackedNavigatorFactory.<init>(BrowserBackedNavigatorFactory.groovy:31)
        at geb
.Configuration.createNavigatorFactory(Configuration.groovy:413)
        at geb
.Browser.createNavigatorFactory(Browser.groovy:982)
        at geb
.Browser.getNavigatorFactory(Browser.groovy:170)
        at geb
.Page.init(Page.groovy:140)
        at geb
.Browser.initialisePage(Browser.groovy:1116)
        at geb
.Browser.createPage(Browser.groovy:829)
        at geb
.Browser.to(Browser.groovy:537)
        at geb
.Browser.to(Browser.groovy:526)
        at geb
.spock.GebSpec.methodMissing(GebSpec.groovy:60)
        at login
.LoginTrait$Trait$Helper.logIn(LoginTrait.groovy:7)

        at test
.TestClass.setupSpec(TestClass.groovy:8)


       
Caused by:
        java
.lang.reflect.InvocationTargetException
            at geb
.driver.CloudDriverFactory.create(CloudDriverFactory.groovy:51)

            at script15726565316811155837962
.run_closure2(script15726565316811155837962.groovy:20)
            at script15726565316811155837962
.run_closure2(script15726565316811155837962.groovy)

            at geb
.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
           
... 19 more

           
Caused by:

            org
.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

           
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'

           
System info: host: 'server', ip: '1.2.3.4', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-957.21.3.el7.x86_64', java.version: '1.8.0_212'
           
Driver info: driver.version: RemoteWebDriver
                at org
.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:573)
                at org
.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
                at org
.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
                at org
.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
               
... 23 more

               
Caused by:
                java
.net.ProtocolException: Unexpected status line:
                    at okhttp3
.internal.http.StatusLine.parse(StatusLine.java:69)
                    at okhttp3
.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
                    at okhttp3
.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
                    at okhttp3
.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                    at okhttp3
.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
                    at org
.openqa.selenium.remote.internal.OkHttpClient$Factory$1.lambda$createClient$1(OkHttpClient.java:152)
                    at okhttp3
.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                    at okhttp3
.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
                    at okhttp3
.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                    at okhttp3
.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
                    at okhttp3
.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
                    at okhttp3
.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                    at okhttp3
.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
                    at okhttp3
.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
                    at okhttp3
.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                    at okhttp3
.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
                    at okhttp3
.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                    at okhttp3
.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
                    at okhttp3
.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
                    at okhttp3
.RealCall.execute(RealCall.java:77)
                    at org
.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:103)
                    at org
.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:105)
                    at org
.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
                    at org
.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
                    at org
.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
                   
... 26 more


Ben Frey

unread,
Nov 4, 2019, 11:42:36 AM11/4/19
to Geb User Mailing List
I may have found what's interfering. I tried to log in to our proxy in my browser (e.g. http://sauceId:suac...@test.company.com:443/wd/hub) and got funky Unicode characters. The person helping out from within my company said I need to use HTTPS instead of HTTP. I tried that and got an error XML from our Layer7 appliance. Is there a way to change https://github.com/geb/geb/blob/v3.0.1/module/geb-core/src/main/groovy/geb/driver/SauceLabsDriverFactory.groovy#L28 so it can use HTTPS if requested?

                    at okhttp3
.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java<s

Marcin Erdmann

unread,
Nov 4, 2019, 3:32:59 PM11/4/19
to geb-...@googlegroups.com
I think the easiest way for now will be to extend SauceLabsDriverFactory and override assembleProviderUrl(). That url should probably use https anyway, I've created an issue to address that: https://github.com/geb/issues/issues/599.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/531a5955-4be3-4f6f-ac60-cb66b953aa83%40googlegroups.com.

Ben Frey

unread,
Nov 5, 2019, 9:31:49 AM11/5/19
to Geb User Mailing List
I think I got it working, at least locally (there's some problem with the GitLab runner in my project currently that I assume is unrelated). I extended SauceLabsDriverFactory, and I also had to pass the credentials in the capabilities method like this:
create('internet explorer') {
    capabilities
(
            browserName
: 'Internet Explorer',
            platform
: 'Windows 7',
            version
: '11',
            parentTunnel
: 'company_admin',

            tunnelIdentifier
: 'company-ha-tunnel',
            username
: System.getenv(SauceAccount.USER_ENV_VAR),
            accessKey
: System.getenv(SauceAccount.ACCESS_KEY_ENV_VAR)
   
)
}


The only hangup now is that each time I run it it creates a new tunnel under my username rather than using one of the existing tunnels. I think that's probably a better question for SauceLabs though, correct?


On Monday, November 4, 2019 at 2:32:59 PM UTC-6, Marcin Erdmann wrote:
I think the easiest way for now will be to extend SauceLabsDriverFactory and override assembleProviderUrl(). That url should probably use https anyway, I've created an issue to address that: https://github.com/geb/issues/issues/599.

On Mon, Nov 4, 2019 at 4:42 PM Ben Frey <sparta...@gmail.com> wrote:
I may have found what's interfering. I tried to log in to our proxy in my browser (e.g. http://sauceId:suaceKey@test.company.com:443/wd/hub) and got funky Unicode characters. The person helping out from within my company said I need to use HTTPS instead of HTTP. I tried that and got an error XML from our Layer7 appliance. Is there a way to change https://github.com/geb/geb/blob/v3.0.1/module/geb-core/src/main/groovy/geb/driver/SauceLabsDriverFactory.groovy#L28 so it can use HTTPS if requested?
To unsubscribe from this group and stop receiving emails from it, send an email to geb-...@googlegroups.com.

Marcin Erdmann

unread,
Nov 6, 2019, 5:12:11 PM11/6/19
to geb-...@googlegroups.com
The gradle plugin will always open a tunnel unless you disable it: https://gebish.org/manual/current/#disabling-sauceconnect

On Tue, Nov 5, 2019 at 2:31 PM Ben Frey <sparta...@gmail.com> wrote:
I think I got it working, at least locally (there's some problem with the GitLab runner in my project currently that I assume is unrelated). I extended SauceLabsDriverFactory, and I also had to pass the credentials in the capabilities method like this:
create('internet explorer') {
    capabilities
(
            browserName
: 'Internet Explorer',
            platform
: 'Windows 7',
            version
: '11',
            parentTunnel
: 'company_admin',
            tunnelIdentifier
: 'company-ha-tunnel',
            username
: System.getenv(SauceAccount.USER_ENV_VAR),
            accessKey
: System.getenv(SauceAccount.ACCESS_KEY_ENV_VAR)
   
)
}


The only hangup now is that each time I run it it creates a new tunnel under my username rather than using one of the existing tunnels. I think that's probably a better question for SauceLabs though, correct?


On Monday, November 4, 2019 at 2:32:59 PM UTC-6, Marcin Erdmann wrote:
I think the easiest way for now will be to extend SauceLabsDriverFactory and override assembleProviderUrl(). That url should probably use https anyway, I've created an issue to address that: https://github.com/geb/issues/issues/599.

On Mon, Nov 4, 2019 at 4:42 PM Ben Frey <sparta...@gmail.com> wrote:
I may have found what's interfering. I tried to log in to our proxy in my browser (e.g. http://sauceId:suac...@test.company.com:443/wd/hub) and got funky Unicode characters. The person helping out from within my company said I need to use HTTPS instead of HTTP. I tried that and got an error XML from our Layer7 appliance. Is there a way to change https://github.com/geb/geb/blob/v3.0.1/module/geb-core/src/main/groovy/geb/driver/SauceLabsDriverFactory.groovy#L28 so it can use HTTPS if requested?
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/f2b9da8c-6e70-47a7-b427-4507eefd00ae%40googlegroups.com.

Ben Frey

unread,
Nov 6, 2019, 5:22:48 PM11/6/19
to Geb User Mailing List
 Oh, I thought that was for if you don't want to use a tunnel at all. Sure enough, setting that doesn't create an extra tunnel in our SauceLabs instance. Thanks for all of your patience, I really appreciate it!

Marcin Erdmann

unread,
Nov 6, 2019, 5:39:39 PM11/6/19
to geb-...@googlegroups.com
Does that mean that we've finally arrived at a working solution? If that's the case then this is most likely the longest thread ending in success on this list. Like ever. :)

On Wed, Nov 6, 2019 at 10:22 PM Ben Frey <sparta...@gmail.com> wrote:
 Oh, I thought that was for if you don't want to use a tunnel at all. Sure enough, setting that doesn't create an extra tunnel in our SauceLabs instance. Thanks for all of your patience, I really appreciate it!

--
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.

Ben Frey

unread,
Nov 6, 2019, 8:48:51 PM11/6/19
to Geb User Mailing List
Pretty much! One last question that's more for niceness's sake: how do I pass the success or failure of the job to SauceLabs? Right now it's just saying "completed".


On Wednesday, November 6, 2019 at 4:39:39 PM UTC-6, Marcin Erdmann wrote:
Does that mean that we've finally arrived at a working solution? If that's the case then this is most likely the longest thread ending in success on this list. Like ever. :)

On Wed, Nov 6, 2019 at 10:22 PM Ben Frey <sparta...@gmail.com> wrote:
 Oh, I thought that was for if you don't want to use a tunnel at all. Sure enough, setting that doesn't create an extra tunnel in our SauceLabs instance. Thanks for all of your patience, I really appreciate it!

--
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-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages