Webdriver.io crashes with NoSessionIdError

I am trying to get webdriver.io and Jasmine to work.

After their example, my script is in test/specs/first/test2.js (as configured) and contains:

 var webdriverio = require('webdriverio'); describe('my webdriverio tests', function() { var client = {}; jasmine.DEFAULT_TIMEOUT_INTERVAL = 9999999; beforeEach(function() { client = webdriverio.remote({ desiredCapabilities: {browserName: 'firefox'} }); client.init(); }); it('test it', function(done) { client .url("http://localhost:3000/") .waitForVisible("h2.btn.btn-primary") .click("h2.btn.btn-primary") .waitForVisible("h2.btn.btn-primary") .call(done); }); afterEach(function(done) { client.end(done); }); }); 

I use wdio as a test runner and configure it using the interactive setup. This config is automatically generated and everything is quite simple, so I do not see the need to publish it.

In another terminal window, I run selenium-server-andalone-2.47.1.jar with Java 7. I have Firefox installed on my computer (it starts when the test starts), and my computer runs OS 10.10.5.

This is what happens when I run the test runner:

 $ wdio wdio.conf.js ======================================================================================= Selenium 2.0/webdriver protocol bindings implementation with helper commands in nodejs. For a complete list of commands, visit http://webdriver.io/docs.html. ======================================================================================= [18:17:22]: SET SESSION ID 46731149-79aa-412e-b9b5-3d32e75dbc8d [18:17:22]: RESULT {"platform":"MAC","javascriptEnabled":true,"acceptSslCerts":true,"browserName":"firefox","rotatable":false,"locationContextEnabled":true,"webdriver.remote.sessionid":"46731149-79aa-412e-b9b5-3d32e75dbc8d","version":"40.0.3","databaseEnabled":true,"cssSelectorsEnabled":true,"handlesAlerts":true,"webStorageEnabled":true,"nativeEvents":false,"applicationCacheEnabled":true,"takesScreenshot":true} NoSessionIdError: A session id is required for this command but wasn't found in the response payload at waitForVisible("h2.btn.btn-primary") - test2.js:21:14 /usr/local/lib/node_modules/webdriverio/node_modules/q/q.js:141 throw e; ^ NoSessionIdError: A session id is required for this command but wasn't found in the response payload 0 passing (3.90s) $ 

I find this very strange and inexplicable, especially considering that it even prints the session id.

Any ideas?

+5
source share
2 answers

Please check out the docs on the wdio test runner. You do not need to create an instance using init yourself. The wdio tester takes care of creating and ending the session for you.

Your example deals with the standalone use of WebdriverIO (without testrunner). You can find examples in which wdio is here .

To clarify this, there are two ways to use WebdriverIO. You can integrate it into your test system yourself (using it as a standalone / or as a scraper). Then you need to take care of things like creating and completing an instance, or starting parallel operations. Another way to use WebdriverIO is to use its wdio test runner. Testrunner accepts a configuration file with a ton of information about your test setup, and spawns instances update information about working in Sauce Labs, etc.

+4
source

Each Webdriver command runs asynchronously. You correctly called the done afterEach in afterEach and in your test it , but you forgot to do it in beforeEach :

 beforeEach(function(done) { client = webdriverio.remote({ desiredCapabilities: {browserName: 'firefox'} }); client.init(done); }); 
+2
source

All Articles