pka
pka

Reputation: 183

SessionNotCreatedException: Tried to run command without establishing a connection error using Selenium GeckoDriver and Firefox through Java

My browser is crashing at random places in my selenium java script. Sometime it does not seem to put text into input boxes as well. When this happen, sometime I see a gecko-driver lurking in task-manager, but not every time.

I have captured gecko trace logs. Can't get dump of browser, as when I try giving it a profile directory

arguments to gecko driver : ["-profile", "C:/Temp/FFProfiles/tmp"]

, it does create new profile in that but then can't connect to browser (waits for a minute then error is thrown)

Env:

Java-1.8, Win-7, tomcat-8.0.30

Tried firefox driver v-3.11.0.jar to 3.141.59.jar

chrome driver v-3.11.0.jar to 3.141.59.jar,

selenium-server-standalone-3.11.0.jar to 3.141.59.jar

Tried headless and head..

Below are the stacktrace from application: at this time it broke while finding an element (ie browser was crashed at previous operation), other times crashes at other places..

org.openqa.selenium.SessionNotCreatedException: Tried to run command without establishing a connection
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
System info: host: 'PC-17', ip: '199.248.254.10', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 59.0.3, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: true, moz:processID: 9584, moz:profile: C:\Users\admin\AppData\Loca..., moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: XP, platformName: XP, platformVersion: 6.1, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
Session ID: a8f6763c-d54b-49e8-a2e2-fda1b8ed6462
*** Element info: {Using=xpath, value=//div[@id='addresIMB']//P}
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
    at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:346)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementsByXPath(RemoteWebDriver.java:425)
    at org.openqa.selenium.By$ByXPath.findElements(By.java:356)
    at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:307)
    at com.selenium.test.AddressParser.getAddressErrors(AddressParser.java:96)

Gecko TRACE logs

1560940131819   geckodriver INFO    geckodriver 0.19.1
1560940131830   geckodriver INFO    Listening on 127.0.0.1:9814
1560940133692   mozrunner::runner   INFO    Running command: "C:/pk/Chrome_Downloads/Firefox_59.0.3_Sel_Executable/firefox.exe" "-marionette" "-width=1920" "-height=1080" "-disable-extensions" "-user-agent=Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0" "-headless" "-profile" "C:\\Users\\admin\\AppData\\Local\\Temp\\rust_mozprofile.37odkVGHuO98"
1560940134786   geckodriver::marionette TRACE     connection attempt 0/600
1560940135898   geckodriver::marionette TRACE     connection attempt 1/600
*** You are running in headless mode.
1560940137000   geckodriver::marionette TRACE     connection attempt 2/600
1560940138103   geckodriver::marionette TRACE     connection attempt 3/600
1560940139207   geckodriver::marionette TRACE     connection attempt 4/600
1560940140216   Marionette  DEBUG   Received observer notification "profile-after-change"
1560940140303   geckodriver::marionette TRACE     connection attempt 5/600
1560940140928   Marionette  DEBUG   Received observer notification "command-line-startup"
1560940140928   Marionette  INFO    Enabled via --marionette
1560940141407   geckodriver::marionette TRACE     connection attempt 6/600
1560940142509   geckodriver::marionette TRACE     connection attempt 7/600
1560940143610   geckodriver::marionette TRACE     connection attempt 8/600
1560940144794   geckodriver::marionette TRACE     connection attempt 9/600
1560940145895   geckodriver::marionette TRACE     connection attempt 10/600
1560940146996   geckodriver::marionette TRACE     connection attempt 11/600
1560940148118   geckodriver::marionette TRACE     connection attempt 12/600
1560940149223   geckodriver::marionette TRACE     connection attempt 13/600
1560940150086   Marionette  DEBUG   Received observer notification "sessionstore-windows-restored"
1560940150330   geckodriver::marionette TRACE     connection attempt 14/600
1560940151424   geckodriver::marionette TRACE     connection attempt 15/600
1560940152446   Marionette  DEBUG   Setting recommended pref toolkit.cosmeticAnimations.enabled to false
1560940152448   Marionette  DEBUG   Setting recommended pref datareporting.policy.dataSubmissionPolicyAccepted to false
1560940152450   Marionette  DEBUG   New connections are accepted
1560940152452   Marionette  INFO    Listening on port 54952
1560940152528   geckodriver::marionette DEBUG   Connected to Marionette on localhost:54952
1560940152808   Marionette  DEBUG   Accepted connection 0 from 127.0.0.1:55000
1560940152853   geckodriver::marionette TRACE   <- {"applicationType":"gecko","marionetteProtocol":3}
1560940152853   geckodriver::marionette TRACE   -> 163:[0,1,"newSession",{"acceptInsecureCerts":true,"browserName":"firefox","capabilities":{"desiredCapabilities":{"acceptInsecureCerts":true,"browserName":"firefox"}}}]
1560940152874   Marionette  TRACE   0 -> [0,1,"newSession",{"acceptInsecureCerts":true,"browserName":"firefox","capabilities":{"desiredCapabilities":{"acceptInsecureCerts":true,"browserName":"firefox"}}}]
1560940152874   Marionette  WARN    TLS certificate errors will be ignored for this session
1560940153180   Marionette  DEBUG   Register listener.js for window 4294967297
1560940153190   Marionette  TRACE   0 <- [1,1,null,{"sessionId":"a8f6763c-d54b-49e8-a2e2-fda1b8ed6462","capabilities":{"browserName":"firefox","browserVersion":"59.0. ... AppData\\Local\\Temp\\rust_mozprofile.37odkVGHuO98","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true}}]
1560940153342   geckodriver::marionette TRACE   <- [1,1,null,{"sessionId":"a8f6763c-d54b-49e8-a2e2-fda1b8ed6462","capabilities":{"browserName":"firefox","browserVersion":"59.0.3","platformName":"windows_nt","platformVersion":"6.1","pageLoadStrategy":"normal","acceptInsecureCerts":true,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"moz:accessibilityChecks":false,"moz:headless":true,"moz:processID":9584,"moz:profile":"C:\\Users\\admin\\AppData\\Local\\Temp\\rust_mozprofile.37odkVGHuO98","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true}}]
1560940153345   webdriver::server   DEBUG   <- 200 OK {"value": {"sessionId":"a8f6763c-d54b-49e8-a2e2-fda1b8ed6462","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"59.0.3","moz:accessibilityChecks":false,"moz:headless":true,"moz:processID":9584,"moz:profile":"C:\\Users\\admin\\AppData\\Local\\Temp\\rust_mozprofile.37odkVGHuO98","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"windows_nt","platformVersion":"6.1","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
1560940153457   webdriver::server   DEBUG   -> POST /session/a8f6763c-d54b-49e8-a2e2-fda1b8ed6462/timeouts {"pageLoad":300000}
1560940153458   geckodriver::marionette TRACE   -> 39:[0,2,"setTimeouts",{"pageLoad":300000}]
1560940153596   Marionette  TRACE   0 -> [0,2,"setTimeouts",{"pageLoad":300000}]
1560940153598   Marionette  TRACE   0 <- [1,2,null,{}]
..............
..................
..............
..................
..............
..................
1560940604266   Marionette  TRACE   0 -> [0,191,"executeScript",{"args":[],"newSandbox":false,"script":"var source = document.documentElement.outerHTML; \nif (!source) { source = new XMLSerializer().serializeToString(document); }\nreturn source;","scriptTimeout":null,"specialPowers":false}]
1560940604292   Marionette  TRACE   0 <- [1,191,null,{"value":"<html dir=\"ltr\" class=\"noie".......... </iframe><div id=\"a-popover-modal\"></div></body></html>"}]
1560940604369   geckodriver::marionette TRACE   <- [1,191,null,{"value":"<html dir=\"ltr\" class=\"noie ......</iframe><div id=\"a-popover-modal\"></div></body></html>"}]
156094060551560940605496    Marionette  TRACE   0 -> [0,192,"quit",{"flags":["eForceQuit"]}]
1560940605498   Marionette  DEBUG   New connections will no longer be accepted
07  webdriver::server   DEBUG   -> DELETE /session/a8f6763c-d54b-49e8-a2e2-fda1b8ed6462 
JavaScript warning: https://images-na.ssl-images-abcd.com/images/G/01/AUIClients/FWCIMAssets.51c2a8513bb855c92a49e78dbeab4f9e24afeb55._V2_.js, line 385: Error: WebGL warning: Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://images-na.ssl-images-abcd.com/images/G/01/AUIClients/FWCIMAssets.51c2a8513bb855c92a49e78dbeab4f9e24afeb55._V2_.js, line 385: Error: WebGL warning: Failed to create WebGL context: WebGL creation failed: 
* Can't use WebGL in headless mode (https://bugzil.la/1375585).
1560940605512   geckodriver::marionette TRACE   -> 39:[0,192,"quit",{"flags":["eForceQuit"]}]
1560940605561   webdriver::server   DEBUG   <- 200 OK {"value":"<html dir=\"ltr\" class=\"noie .........function L(a){var b=g.ue_csm_markers||{},c;for(c in b)b.hasOwnProperty(c)&&t(c,a,y,b[c])}function u(d,b,c){c=c||g;a.ue_pel&&window.EventTarget&&window.EventTarget.prototype&&window.EventTarget.prototype.addEventListener?window.EventTarget.prototype.addEventListener.call(c,d,b,!!window.ue_clf):c.addEventListener?c.addEventListener(d,b,!!window.ue_clf):c.attachEvent&&c.attachEvent(\"on\"+d,b)}\nfunction E(d,b,c){c=c||g;a.ue_pel&&window.EventTarget&&window.EventTarget.protot1ype&&window.Even560940605610   Marionette  TRACE   0 <- [1,192,null,{"cause":"shutdown"}]
...........\n\n\n1560940605764  Marionette  DEBUG   Closed connection 0
\n.......</iframe><div id=\"a-popover-modal\"></div></body></html>"}
Unable to read VR Path Registry from C:\Users\admin\AppData\Local\openvr\openvrpaths.vrpath
[Child 12684, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
Unable to read VR Path Registry from C:\Users\admin\AppData\Local\openvr\openvrpaths.vrpath
[Parent 9584, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 12684, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 12312, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 12312, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
1560940605673   geckodriver::marionette TRACE   <- [1,192,null,{"cause":"shutdown"}]
1560940607022   webdriver::server   DEBUG   Deleting session
1560940607023   geckodriver::marionette DEBUG   Stopping browser process
1560940607096   webdriver::server   DEBUG   -> POST /session/a8f6763c-d54b-49e8-a2e2-fda1b8ed6462/elements {"value":"//div[@id='addressIMB']//P","using":"xpath"}
1560940608819   webdriver::server   DEBUG   <- 200 OK {"value": {}}
1560940608819   webdriver::server   DEBUG   <- 500 Internal Server Error {"value":{"error":"session not created","message":"Tried to run command without establishing a connection","stacktrace":"stack backtrace:\n   0:           0x47e934 - <no info>\n   1:           0x47f0a3 - <no info>\n   2:           0x442511 - <no info>\n   3:           0x42a686 - <no info>\n   4:           0x406f5e - <no info>\n   5:           0x40cfc9 - <no info>\n   6:           0x6bef19 - <no info>\n   7:           0x420756 - <no info>\n   8:           0x6b96e0 - <no info>\n   9:         0x770459cd - BaseThreadInitThunk"}}

Upvotes: 2

Views: 4675

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193108

This error message...

org.openqa.selenium.SessionNotCreatedException: Tried to run command without establishing a connection
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
System info: host: 'PC-17', ip: '199.248.254.10', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'

...implies that the GeckoDriver was unable to initiate/spawn a new WebBrowsing Session i.e. Firefox Browser session.

Your main issue is the incompatibility between the version of the binaries you are using as follows:

  • Your JDK version is 1.8.0_65 which is pretty ancient.

So there is a clear mismatch between the JDK v8u65 and Selenium Client v3.141.59.


Solution

  • Upgrade JDK to recent levels JDK 8u212.
  • Upgrade Selenium to current levels Version 3.141.59.
  • Upgrade GeckoDriver to GeckoDriver v0.24.0 level.
  • GeckoDriver is present in the specified location.
  • GeckoDriver is having executable permission for non-root users.
  • Upgrade Firefox version to Firefox v67.0 levels.

Upvotes: 1

Related Questions