3

I can't seem to run functional tests from the command prompt. Interestingly it works fine with Intellij...

I am using Grails 2.2.0, seleniumVersion = "2.27.0", spockVersion = "spock-grails-support:0.7-groovy-2.0", geb = "0.9.0-RC-1", httpClientVersion = "4.2.3"

This is the error :

 geb.driver.DriverCreationException: failed to create driver from callback 'script13825065657431376537371$_run_closure1@800
4899'
      [...] 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.

ChromeDriver is started (seen in running processes), but obviously it cannot start chrome.

Here is how chromedriver is created in GebConfig.groovy:

  System.setProperty('webdriver.chrome.driver', chromeDriver.absolutePath)
  ChromeDriverService service = new ChromeDriverService.Builder()
      .usingDriverExecutable(new File(chromeDriver.absolutePath))
      .usingAnyFreePort()
      .build()

  ChromeOptions options = new ChromeOptions()
  options.addArguments("user-data-dir=test/drivers/chrome/.config/google-grey-chrome-profile",
      "--disable-webgl",
      "log-path=C:/test/chromedriver.log")
  File chromeBinary = new File("C:/test/Google/Chrome/Application/chrome.exe")
  options.setBinary(chromeBinary)

  new ChromeDriver(service, options)

Note that the path to chromedriver and chrome are given via system property and options respectively And here are the dependencies in BuildConfig.groovy:

dependencies {
[...]
provided("org.apache.httpcomponents:httpclient:$httpClientVersion")

test "org.spockframework:$spockVersion"
// runtime 'mysql:mysql-connector-java:5.1.16'
test("org.gebish:geb-spock:$gebGrailsVersion")
test("org.gebish:geb-junit4:$gebGrailsVersion")
test "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion", { excludes "commons-io", "httpclient", 'nekohtml' }
test "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
test "org.seleniumhq.selenium:selenium-remote-driver:$seleniumVersion"
compile "org.apache.httpcomponents:httpclient:$httpClientVersion"

I have tried a lot of version combinations in vain, and I don't get any logs from chromedriver either, even by passing the log-path in the ChromeOptions.

Update:

I updated grails to 2.2.3, geb to 0.9.2, and now the full stack trace in the command prompt is the following (all still fine in Intellij):

|  geb.driver.DriverCreationException: failed to create driver from callback 'script13856991845071649825131$_run_closure1@91a
94b3'
        at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
        at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:80)
        at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:30)
        at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:79)
        at geb.Configuration.createDriver(Configuration.groovy:354)
        at geb.Configuration.getDriver(Configuration.groovy:343)
        at geb.Browser.getDriver(Browser.groovy:105)
        at geb.Browser.go(Browser.groovy:394)
        at geb.Browser.go(Browser.groovy:386)
        at support.FunctionalSpec.setupSpec_closure1(FunctionalSpec.groovy:13)
        at geb.Browser.drive(Browser.groovy:860)
        at geb.Browser.drive(Browser.groovy:830)
        at support.FunctionalSpec.setupSpec(FunctionalSpec.groovy:12)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:161)
        at script13856991845071649825131.run_closure1(script13856991845071649825131.groovy:44)
        at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
Calahad
  • 1,408
  • 14
  • 22

1 Answers1

1

Try this solution link This I fixed by using the ChromeDriver. Download your version on link, unzip it and use it as followed:

System.setProperty("webdriver.chrome.driver", "<unzip location>/chromedriver");
driver = new ChromeDriver();

And update geb/spock version.

plsgogame
  • 1,334
  • 15
  • 28
  • Thanks, I updated geb/spock to 0.9.2, and I was already giving the path to chromedriver (see first line of my GebConfig). As I mentioned, it starts but doesn't manage to start chrome. The issue remains, it only happens when trying from command line. – Calahad Oct 23 '13 at 22:18
  • so, if you run in Intellij... and all ok, may be you have problems with windows environments? Can you run `grails --version`? or problem with java: `java -version`? – plsgogame Oct 24 '13 at 07:30
  • grails version : 2.2.0, java version "1.7.0_40" Java(TM) SE Runtime Environment (build 1.7.0_40-b43) Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode) – Calahad Oct 24 '13 at 22:38
  • @Calahad I do not know how to help you, but I think problem with env. – plsgogame Oct 25 '13 at 09:00