1

Randomly I get this error "org.openqa.selenium.WebDriverException: connection refused" when running tests in Linux machine with Mozilla Firefox 60.4.0 installed.

Different combinations that I tried were:

1) Selenium 3.12.0 geb-spock:2.1 GeckoDriver 0.18.0

2) Selenium 3.12.0 geb-spock:2.1 GeckoDriver 0.23.0

3) Selenium 3.14.0 geb-spock:2.1 GeckoDriver 0.23.0

I even tried setting xvfb display to an offset of 5. Also, checked any defunt geckodriver and firefox. There were no such defunct processes.

Is there a way to try and catch this "org.openqa.selenium.WebDriverException: connection refused" and then try to create driver again? Anybody know why this error occurs and how to solve this?

Stacktrace:

geb.driver.DriverCreationException: failed to create driver from callback 'script1548780037482534636672$_run_closure1$_closure4$_closure7@288e23a'
    at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
    at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:85)
    at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy)
    at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:32)
    at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:84)
    at geb.Configuration.createDriver(Configuration.groovy:382)
    at geb.Configuration.getDriver(Configuration.groovy:371)
    at geb.Browser.getDriver(Browser.groovy:111)
    at geb.navigator.factory.BrowserBackedNavigatorFactory.<init>(BrowserBackedNavigatorFactory.groovy:35)
    at geb.Configuration.createNavigatorFactory(Configuration.groovy:417)
    at geb.Browser.createNavigatorFactory(Browser.groovy:133)
    at geb.Browser.getNavigatorFactory(Browser.groovy:121)
    at geb.Page.init(Page.groovy:144)
    at geb.Browser.createPage(Browser.groovy:859)
    at geb.Browser.to(Browser.groovy:550)
    at geb.Browser.to(Browser.groovy:539)
    at geb.spock.GebSpec.methodMissing(GebSpec.groovy:56)
    at tests.UserTest.Step 1: user can login(UserTest.groovy:40)
Caused by: org.openqa.selenium.WebDriverException: connection refused
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'va1c143', ip: '10.20.10.77', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-754.9.1.el6.x86_64', java.version: '1.8.0_191'
Driver info: driver.version: FirefoxDriver
remote stacktrace: stack backtrace:
   0:           0x5787ed - backtrace::backtrace::trace::h59229d13f6a8837d
   1:           0x578942 - backtrace::capture::Backtrace::new::h23089c033eded8f0
   2:           0x4463cc - webdriver::error::WebDriverError::new::hd11f864b1fdf4510
   3:           0x450591 - geckodriver::marionette::MarionetteHandler::create_connection::h6f7058fccafe4367
   4:           0x425c32 - <webdriver::server::Dispatcher<T, U>>::run::h8f5348b8f5f7c053
   5:           0x40b22c - std::panicking::try::do_call::hb67c6fb6bcd96195
   6:           0x5dc20a - panic_unwind::__rust_maybe_catch_panic
                        at /checkout/src/libpanic_unwind/lib.rs:98
   7:           0x41b943 - <F as alloc::boxed::FnBox<A>>::call_box::h4100941edc372034
   8:           0x5d48a4 - alloc::boxed::{{impl}}::call_once<(),()>
                        at /checkout/src/liballoc/boxed.rs:650
                         - std::sys_common::thread::start_thread
                        at /checkout/src/libstd/sys_common/thread.rs:21
                         - std::sys::imp::thread::{{impl}}::new::thread_start
                        at /checkout/src/libstd/sys/unix/thread.rs:84
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
    at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
    at script1548780037482534636672$_run_closure1.closure4$_closure7(script1548780037482534636672.groovy:17)
    at script1548780037482534636672$_run_closure1.closure4$_closure7(script1548780037482534636672.groovy)
    at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Ramesh
  • 681
  • 7
  • 15
  • Hi there. I answered you on the Geb mailing list and we agreed that this is not a Geb problem. Did you do anything else here, like report to the GeckoDriver team? Or can you prepare an [MCVE](http://stackoverflow.com/help/mcve) for everyone to clone from GitHub, build, run and reproduce your problem? – kriegaex Feb 10 '19 at 01:03
  • reported this issue in geckodriver https://github.com/mozilla/geckodriver/issues/1500 – Ramesh Feb 11 '19 at 20:38
  • And again, there you also did not add an [MCVE](http://stackoverflow.com/help/mcve)but only report the problem. I think your chances to get a solution with a callstack but no code will be quite low. You should help your helpers to help you! Good luck anyway. – kriegaex Feb 12 '19 at 00:58

1 Answers1

1

This error message...

geb.driver.DriverCreationException: failed to create driver from callback 'script1548780037482534636672$_run_closure1$_closure4$_closure7@288e23a'

...implies that the geb was unable to initiate/spawn a new GeckoDriver process.

There can be multiple reasons behind this issue as follows:

  • As per geb.driver.DriverCreationException: failed to create driver from callback

    • You need to provide the absolute path of the GeckoDriver within GebConfig as follows:

      driver = {
         System.setProperty('webdriver.gecko.driver', '/path/to/geckodriver')
         new FirefoxDriver()
      }
      
    • Ensure that Firefox browser is installed.

    • Ensure that GeckoDriver version is compatible with Selenium and Firefox versions as per the following matrix:

Geckodriver Releases_till_24

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I have everything setup correctly like you mentioned. How come it works fine most of the time without any errors? I get this error only after a few runs and it happens randomly. I will try to run with GeckoDriver versions 0.22.0, 0.21.0 versions and see. – Ramesh Jan 31 '19 at 17:14