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() }
}



On Friday, October 25, 2019 at 2:47:15 AM UTC-5, Marcin Erdmann wrote:
>
> 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. :)
>
> On Thu, Oct 24, 2019 at 8:21 PM Ben Frey <[email protected] 
> <javascript:>> wrote:
>
>> 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?
>>
>>
>> On Wednesday, October 23, 2019 at 3:56:49 PM UTC-5, Marcin Erdmann wrote:
>>>
>>> The issue you created Ben looks good, thanks!
>>>
>>> On Wed, Oct 23, 2019 at 6:27 PM Ben Frey <[email protected]> wrote:
>>>
>>>> Alright, I created https://github.com/geb/issues/issues/597. Please 
>>>> let me know if you'd like any more details in the issue.
>>>>
>>>> On Wednesday, October 23, 2019 at 8:09:53 AM UTC-5, Marcin Erdmann 
>>>> wrote:
>>>>>
>>>>> 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.
>>>>>
>>>>> On Wed, Oct 23, 2019 at 1:59 PM Ben Frey <[email protected]> wrote:
>>>>>
>>>>>> 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.
>>>>>>
>>>>>> On Wednesday, October 23, 2019 at 7:55:08 AM UTC-5, Marcin Erdmann 
>>>>>> wrote:
>>>>>>>
>>>>>>> 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.
>>>>>>>
>>>>>>> On Wed, Oct 23, 2019 at 1:28 PM Ben Frey <[email protected]> 
>>>>>>> wrote:
>>>>>>>
>>>>>>>> ./gradlew clean testTaskName
>>>>>>>>
>>>>>>>> where "testTaskName" is a Gradle task defined like this
>>>>>>>> task testTaskName(type: Test) {
>>>>>>>>     filter {
>>>>>>>>         includeTestsMatching 'stufftotest.*'
>>>>>>>>     }
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wednesday, October 23, 2019 at 6:27:12 AM UTC-5, Marcin Erdmann 
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> What's the Gradle task that you are running in CI?
>>>>>>>>>
>>>>>>>>> On Tue, Oct 22, 2019 at 6:33 PM Ben Frey <[email protected]> 
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> 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
>>>>>>>>>>    
>>>>>>>>>> -- 
>>>>>>>>>> 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 [email protected].
>>>>>>>>>> To view this discussion on the web visit 
>>>>>>>>>> https://groups.google.com/d/msgid/geb-user/7545c8f8-e510-4065-8d3c-7c29b67304b0%40googlegroups.com
>>>>>>>>>>  
>>>>>>>>>> <https://groups.google.com/d/msgid/geb-user/7545c8f8-e510-4065-8d3c-7c29b67304b0%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>>>> .
>>>>>>>>>>
>>>>>>>>> -- 
>>>>>>>> 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 [email protected].
>>>>>>>> To view this discussion on the web visit 
>>>>>>>> https://groups.google.com/d/msgid/geb-user/b70f3fe1-acd7-4317-8df6-c74f91d77270%40googlegroups.com
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/geb-user/b70f3fe1-acd7-4317-8df6-c74f91d77270%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>> -- 
>>>>>> 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 [email protected].
>>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/geb-user/21fa1c21-3185-4a12-ab6e-cebc799bf5c1%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/geb-user/21fa1c21-3185-4a12-ab6e-cebc799bf5c1%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>> -- 
>>>> 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 [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/geb-user/8ba12b87-571b-4e65-a317-35c2ee010c5a%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/geb-user/8ba12b87-571b-4e65-a317-35c2ee010c5a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> 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 [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/geb-user/10691e84-4368-4661-b9be-e374f0fbfd87%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/geb-user/10691e84-4368-4661-b9be-e374f0fbfd87%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/geb-user/041a1079-b908-4416-bac7-5ed9e306f090%40googlegroups.com.

Reply via email to