3521

Node.js WebdriverIO errors

Question:

I am trying to run the test script from webdriverIO.

This is the code:

var webdriverio = require('webdriverio'); var options = { desiredCapabilities: { browserName: 'chrome' } }; webdriverio .remote(options) .init() .url('http://www.google.com') .getTitle().then(function(title) { console.log('Title was: ' + title); }) .end() .catch(function(err) { console.log(err); });

When i run this, i get errors that i cannot understand. This is what Node tells me:

C:\...\webdriverio-node>node test.js { Error: A new session could not be created. at end() - C:\...\webdriverio-node\test.js:15:6 details: undefined, message: 'Unable to create session from org.openqa.selenium.remote.NewSessionP ayload@25bd2276\nBuild info: version: \'3.11.0\', revision: \'e59cfb3\', time: \ '2018-03-11T20:33:15.31Z\'\nSystem info: host: \'USER-PC\', ip: \'\', os.name: \'Windows 7\', os.arch: \'amd64\', os.version: \'6.1\', java.vers ion: \'1.8.0_171\'\nDriver info: driver.version: unknown', type: 'RuntimeError', seleniumStack: { type: 'SessionNotCreatedException', message: 'A new session could not be created.', orgStatusMessage: 'Unable to create session from org.openqa.selenium.remote .NewSessionPayload@25bd2276\nBuild info: version: \'3.11.0\', revision: \'e59cfb 3\', time: \'2018-03-11T20:33:15.31Z\'\nSystem info: host: \'USER-PC\', ip: \'\', os.name: \'Windows 7\', os.arch: \'amd64\', os.version: \'6.1\ ', java.version: \'1.8.0_171\'\nDriver info: driver.version: unknown' } }

And this is the message i get from selenium-server-standalone:

16:49:43.014 INFO [ActiveSessionFactory.apply] - Capabilities are: Capabilities {browserName: chrome, handlesAlerts: true, javascriptEnabled: true, locationCont extEnabled: true, loggingPrefs: org.openqa.selenium.logging..., requestOrigins: {name: webdriverio, url: http://webdriver.io, version: 4.12.0}, rotatable: true} 16:49:43.016 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.o penqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selen ium.chrome.ChromeDriverService)

When i change line 4 from the code to:

browserName: 'firefox'

This is the error that Node.js generates:

C:\...\webdriverio-node>node test.js { Error: An unknown server-side error occurred while processing the command. at end() - C:\...\webdriverio-node\test.js:15:6 details: undefined, message: 'Process unexpectedly closed with status -1073741511\nBuild info: ver sion: \'3.11.0\', revision: \'e59cfb3\', time: \'2018-03-11T20:33:15.31Z\'\nSyst em info: host: \'USER-PC\', ip: \'\', os.name: \'Windows 7\', os .arch: \'amd64\', os.version: \'6.1\', java.version: \'1.8.0_171\'\nDriver info: driver.version: unknown\nremote stacktrace: ', type: 'RuntimeError', seleniumStack: { type: 'UnknownError', message: 'An unknown server-side error occurred while processing the comman d.', orgStatusMessage: 'Process unexpectedly closed with status -1073741511\nBui ld info: version: \'3.11.0\', revision: \'e59cfb3\', time: \'2018-03-11T20:33:15 .31Z\'\nSystem info: host: \'USER-PC\', ip: \'\', os.name: \'Win dows 7\', os.arch: \'amd64\', os.version: \'6.1\', java.version: \'1.8.0_171\'\n Driver info: driver.version: unknown\nremote stacktrace: ' } }

And this is what selenium-server-standalone tells me:

16:50:53.332 INFO [ActiveSessionFactory.apply] - Capabilities are: Capabilities {browserName: firefox, handlesAlerts: true, javascriptEnabled: true, locationCon textEnabled: true, loggingPrefs: org.openqa.selenium.logging..., requestOrigins: {name: webdriverio, url: http://webdriver.io, version: 4.12.0}, rotatable: true } 16:50:53.335 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.o penqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selen ium.firefox.GeckoDriverService) 1524577853389 geckodriver INFO geckodriver 0.20.0 1524577853399 geckodriver INFO Listening on 127.0.0.1:42211 1524577854396 mozrunner::runner INFO Running command: "C:\\Program Fi les (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\Us er\\AppData\\Local\\Temp\\rust_mozprofile.oSWu443RM4TY"

I am using selenium-server-standalone-3.11.0.jar

Answer1:

This is because appropriate binary could not be found. Checkout this <a href="http://webdriver.io/guide/getstarted/install.html#Setup-Chrome" rel="nofollow">Setup-Chrome</a> section of webdriver.io

<blockquote>

With the latest version of Selenium most of the drivers for the browser come with an external driver that has to be downloaded and setup.

</blockquote>

Download the latest version of chromedriver from <a href="https://sites.google.com/a/chromium.org/chromedriver/home" rel="nofollow">chromedriver</a> for OS and either place it in the same location as ur test.js or set a PATH in windows. It would be automatically picked up. I only tried it with chrome and was able to execute your code successfully.

Personally I use <a href="https://www.npmjs.com/package/webdriver-manager" rel="nofollow">webdriver-manager</a> to manager binaries

npm install webdriver-manager

webdriver-manager update

webdriver-manager start

This will setup all required binary drivers to connect to browser

Answer2:

I was able to solve the firefox part, just be reinstalling Firefox, as the browser installation was corrupted.

Unfortunately though, i was dissapointed that WebdriverIO spawned the Firefox browser before i get back my result.

I don't know if it's possible to run it in headless mode.

Recommend

  • Kubernetes 1.8.10 kube-apiserver priorityclasses error
  • Eclipse rendering problems
  • CMake cl.exe is not able to compile a simple test program
  • Setup buildroot for old kernels
  • Can't run docker on os X with boot2docker
  • Why gcc does not produce type mismatch warning for int and char?
  • createFileAtPath & OCUnit & errno blues
  • How do I split Tensorflow datasets?
  • curl not working for getting a web page content, why?
  • “cpanm PHP” fails
  • Why isn't Kubernetes service DNS working?
  • Java: java.util.ConcurrentModificationException
  • jQuery timepicker 'Object does not support this property or method'
  • Titanium doesn't recognize Android SDK on Windows
  • Boost binary serialization doesn't work occasionally. The parsed data is corrupted sometimes
  • 3.0.0.M1: SSL - Invalid keystore format
  • RabbitMQ java client stops consuming messages
  • Appium MobileElement swipe returns unknown server error
  • Spark (Scala) Writing (and reading) to local file system from driver
  • How to rotate the dial in a gauge chart? Using python plotly
  • apply a javascript function to draggable copy
  • Building Qt project for C++11 standard
  • pip in virtualenv gets ConnectTimeoutError
  • How to install node-mysql?
  • pyodbc doesn't report sql server error
  • Is it possible to access block's scope in method?
  • RectangularRangeIndicator format like triangular using dojo
  • C# - Serializing and deserializing static member
  • Sony Xperia Z Tablet not found by adb
  • Cross-Platform Protobuf Serialization
  • Javascript convert timezone issue
  • 'TypeError' while using NSGA2 to solve Multi-objective prob. from pyopt-sparse in OpenMDAO
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • Apache 2.4 - remove | delete | uninstall
  • How to format a variable of double type
  • Cannot Parse HTML Data Using Android / JSOUP
  • How do you join a server to an Active Directory (domain)?
  • Understanding cpu registers
  • coudnt use logback because of log4j
  • JaxB to read class hierarchy