Hello,

I've been trying to get a cucumber test scenario to run in multiple 
browsers in saucelabs but not successful so far. Here is my non parallel 
set up of everything:

In GebConfig.groovy:


environments {

    sauce {
        driver = {
            def username = System.getenv("SAUCE_USERNAME")
            assert username
            def accessKey = System.getenv("SAUCE_ACCESS_KEY")
            assert accessKey

            DesiredCapabilities capabilities = new DesiredCapabilities()
            capabilities.setBrowserName(System.getProperty("BROWSER_NAME"))
            
capabilities.setPlatform(Platform.fromString(System.getProperty("PLATFORM")))
            capabilities.setVersion(System.getProperty("VERSION"))
            capabilities.setCapability("build", System.getenv("BUILD_TAG"));

            new RemoteWebDriver(new 
URL("http://$username:[email protected]:80/wd/hub";), 
capabilities)

        }
    }
}


I'm using cucumber tests so using I have cucumber hooks for Before and After 
executing a scenario.


This is my Before hook

Before() { scenario ->
    Logger.getInstance().updateScenarioReference((ScenarioImpl) scenario)
    theBrowser = new Browser()

}



After hook:

After() { scenario ->
    if (scenario.failed) {
        Logger.getInstance().addMessage(new ScenarioFailedMsg((String) 
scenario.name))
    }
    if (System.getProperty("geb.env").contains("sauce")) {
        updateSauceLabs(scenario, theBrowser)
    }

    if (theBrowser.config.autoClearCookies) {
        theBrowser.clearCookiesQuietly()
    }
    CachingDriverFactory.clearCacheAndQuitDriver()
}

void updateSauceLabs(Scenario scenario, Browser theBrowser) {
    String jobID = 
((RemoteWebDriver)theBrowser.driver).getSessionId().toString()

    SauceREST client = new SauceREST(System.getenv("SAUCE_USERNAME"), 
System.getenv("SAUCE_ACCESS_KEY"))
    Map<String, Object> sauceJob = new HashedMap()
    sauceJob.put("name", scenario.getName() + " :: " + 
System.getProperty("BROWSER_NAME")+ " :: " + System.getenv("BUILD_TAG"))
    if (scenario.isFailed()) {
        client.jobFailed(jobID)
    } else {
        client.jobPassed(jobID)
    }
    client.updateJobInfo(jobID, sauceJob)
    printSessionId(scenario, theBrowser)

} 



To introduce parallel multi-browser testing in saucelabs, here is what i tried:


Updated sauce driver in GebConfig.groovy:


sauce {
    driver = {
        def username = System.getenv("SAUCE_USERNAME")
        assert username
        def accessKey = System.getenv("SAUCE_ACCESS_KEY")
        assert accessKey

        def browsers = System.getProperty("browsers").split(',')
        GParsPool.withPool {
            browsers.eachParallel { browser ->
                println "Browser name is "+browser.toString()
                DesiredCapabilities capabilities = new DesiredCapabilities()
                capabilities.setBrowserName(browser.toString())
                
capabilities.setPlatform(Platform.fromString(System.getProperty("PLATFORM")))
                capabilities.setVersion(System.getProperty("VERSION"))
                capabilities.setCapability("build", System.getenv("BUILD_TAG"));
                def driver = new RemoteWebDriver(new 
URL("http://$username:[email protected]:80/wd/hub";), 
capabilities)
                println "Session id= " +driver.sessionId
                driver
            }
        }

    }
}


But this didn't work properly as whenever I do 


(RemoteWebDriver)theBrowser.driver, this return all the browsers I provided in 
System.getProperty("browsers") and that results in an error


Could you please help me understand how and where do I introduce parallelism 
here? Is it inside GebConfig or inside cucumber hooks?


Thanks,

Meriya

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/geb-user/608d0f6b-cf8a-438c-b5a9-536d2c86ca47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to