Search code examples
grailsfunctional-testingspockgeb

difference between geb.env and geb.driver


I am trying to find out the difference between geb.driver option against geb.env.

I could not find any concrete documentation on them. I could understand that geb.env is similar to grails.env except, geb env's are defined in GebConfig.groovy.

Then, why do we need geb.driver. More confusing stuff is my functional test cases are working fine if I specify geb.driver but getting error when I use geb.env.

Cannot find window: _PPIdentityWindow_ 
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 22:18:01' 
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.5', java.version: '1.6.0_35' 
Driver info: driver.version: unknown 
org.openqa.selenium.NoSuchWindowException: Cannot find window: _PPIdentityWindow_ 
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 22:18:01' 
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.5', java.version: '1.6.0_35' 
Driver info: driver.version: unknown 
        at org.openqa.selenium.htmlunit.HtmlUnitDriver$HtmlUnitTargetLocator.window(HtmlUnitDriver.java:943) 
        at geb.Browser.switchToWindow(Browser.groovy:458) 
        at geb.Browser.withWindow(Browser.groovy:470) 
        at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51) 

Any help is greatly appretiated. I have asked the same question in grails user mailing list too.

http://grails.1312388.n4.nabble.com/Difference-between-geb-driver-and-geb-env-td4637641.html


Solution

  • When it comes to docs, geb.driver is described here and geb.env is described here.

    The difference is that you can with geb.driver you can only specify which driver to use whereas with geb.env you can specify which environment to use and then specify any environment specific configuration, i.e. base url, waiting, reports dir, and also the driver if you wish.

    The stacktrace seems to have to do with HtmlUnit driver and not Firefox driver. I can see in your mail to the list that you specify HtmlUnit driver as the default and firefox driver wasn't picked up for whatever reason even though you used geb.env=firefox and there is a configuration for that environment in your GebConfig.groovy. Three reasons I can think of are:

    • you havn't specified a dependency on firefox driver jar in BuildConfig.groovy
    • you have forgotten to import FirefoxDriver class in your GebConfig.groovy
    • you specified geb.env property in wrong spot in your command - you have to specify it straight after grails (i.e. grails -Denv.geb=firefox test functional:) otherwise it won't get picked up

    In the future if you have Geb specific questions you should consider posting them to Geb mailing list instead of Grails mailing list, you're more likely to get an answer there.