Hi,
Wondering if this level of parallelism is possible to achieve in Geb?
I'm always using Browser.drive to do various steps inside one cucumber
scenario,
and inside browser.drive, it always initializes a new browser which mean it
will look at GebConfig.groovy to decide which browser to use for.
But in my non-parallel setup, it seems to use a single browser for an
entire scenario. I have specified to quit the browser in the After hook. So
it uses new browser for every scenario.
I cannot seem to wrap my head around how to make parallelism work here. Any
hints I can get on this would be great! Thank you!!
On Thursday, 15 March 2018 13:23:27 UTC-5, meriya thomas wrote:
>
> 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/b2b7aa5e-cb19-4a24-b6c0-294450d05027%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.