Receiving a NoSessionIdError issue when using Webdriver.io

Currently, I am in the process of setting up and configuring webdriver.io and Jasmine.

As per the guidelines provided, my script is located at test/specs/first/test2.js (as per the configuration) and includes the following:

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);
    });
});

For the testing setup, I am using wdio as the test runner, with a configuration that was set up interactively. The configuration is automatically generated and quite straightforward, so I won't be posting it here.

Additionally, in a separate terminal window, I have selenium-server-standalone-2.47.1.jar running with Java 7. Firefox is also installed on my system (it opens up when the test is executed) and my computer is operating on OS 10.10.5.

Upon initiating the test runner, the following logs are displayed:

$ 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)


$

This unexpected behavior, particularly the presence of the session ID in the logs, is quite perplexing to me.

Does anyone have any insights or suggestions for resolving this issue?

Answer №1

Make sure to explore the documentation on the wdio test runner. You don't have to manually initialize an instance. The wdio test runner handles the session creation and termination for you.

Your provided example focuses on using WebdriverIO in a standalone manner (without the test runner). For examples utilizing wdio, visit this link.

Just to clarify, there are two ways of employing WebdriverIO. You can integrate it into your testing setup individually (as a standalone tool or a scraper). In this case, you are responsible for tasks like instance creation, termination, and parallel execution. The alternative approach is to utilize WebdriverIO's test runner, wdio. This test runner operates based on a configuration file containing details about your testing environment, manages instance spawning, updates job details on platforms like Sauce Labs, and more.

Answer №2

Each action performed with Webdriver is executed asynchronously. You remembered to include the done callback in the afterEach function and within your test it test, but unfortunately missed it in the beforeEach function:

beforeEach(function(done) {
    client = webdriverio.remote({ desiredCapabilities: {browserName: 'chrome'} });
    client.init(done);
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Uploading multiple strings to an Amazon S3 bucket using Node.js by piping a string

Suppose I have a simple loop similar to the one shown below: for (const i=0; i<3; i++) { to(`This incrementer is ${i}`) } At the end of the loop, I expect my file to contain: This counter is 0 This counter is 1 This counter is 2 I at ...

Utilize a Chrome Content Script to intercept jQuery delegated event handlers and take control

After developing a Chrome extension that intercepts form submissions in specific circumstances, I encountered an issue with a particular website utilizing jQuery's delegate function. My extension is built with raw JavaScript, excluding jQuery to prev ...

Understanding variable scope in Node.js routing with Javascript

Consider the following code snippet: app.get("/location1", function(req, res){ async_function().then(result => { var str = result.toString(); }).catch(...)..... }); There are variables defined inside the .then() block of the asynchronous ...

Transform the array into an associative array

Below is the array I am working with: print_r($data); When printed in PHP, the result looks like this: $data=Array( [0] => stdClass Object ( [name] => location [value] =>lko ) [1] => stdClass Object ( [n ...

Enable the choice for Bootstrap collapse animation to be customized

Is there a way to allow users or admins on my website to decide whether or not Bootstrap 4 collapse elements should be animated? The concern is that when many elements are moved by the animation, it becomes less smooth. Therefore, it would be ideal to give ...

Does the entire window fade before the URL is loaded?

Is it feasible for me to create an effect where, upon a user clicking on a link, the entire window fades out (perhaps with a black div covering it), and then loads an external URL like 'google'? For example: User clicks 'Here', and th ...

Display just the minutes using react-countdown-circle-timer in a React application

Looking to create a test page in React featuring a countdown timer set at 50 minutes, I integrated the react-countdown-circle-timer module. However, I encountered an issue where the minutes displayed do not change dynamically as they should. My goal is to ...

Obtain text content from a disabled textbox with Selenium

I am currently working with a text box that displays hours ranging from 1 to 24. The hours can be increased or decreased by clicking on Up and Down Arrows (Hyperlinks) located above and below the text box. Below is the code for my text box: <input typ ...

The clicking of a mouse is not causing the element to be highlighted

Issue: The mouse hover action is not highlighting the element when using selenium's mousehover() method. Attempted Solutions: We have tried implementing the three solutions provided in the link, but none of them have been successful in achieving the ...

Unable to utilize Bower due to a node.js malfunction

Currently facing an issue while attempting to utilize bower for installing all necessary components for my website project. Each time I make an attempt, the following error presents itself: TypeError: Object #<Object> has no method 'toLowerCase ...

React - Uncaught Error: e.preventDefault is not a function due to Type Error

Encountering an issue with Axios post and react-hook-form: Unhandled Rejection (TypeError): e.preventDefault is not a function The error arises after adding onSubmit={handleSubmit(handleSubmitAxios)} to my <form>. Seeking to utilize react-hook-form ...

FInding the inner value of a Vuetify chip

I have a Vue application that utilizes Vuetify chips to display information. I'm trying to log the value inside a specific chip when it is clicked, but I keep getting an undefined error when trying to access the array where the information comes from. ...

Tips for displaying an alpha-numeric keyboard in a React Native application

I am struggling to display an alpha-numeric keyboard in my React-Native App. I have tried various values for the keyboardType prop, but none of them seem to work for me. If anyone has any suggestions on how I can achieve this, please do share your ideas w ...

Error encountered in Angular Html2Pdf: Unable to assign the 'adoptedStyleSheets' attribute on 'ShadowRoot' due to DOMException

Looking for assistance in implementing html2pdf with Angular 12 to convert specific parts of an HTML page into a downloadable PDF. ERROR MESSAGE An error occurred while trying to execute the code: index-7a8b7a1c.js:150 Uncaught (in promise) DOMExce ...

Creating Event Handlers for corresponding elements in HTML with the help of JQuery and JavaScript

Struggling with HTML and debugging an issue in my ASP.NET Core App. The problem lies in a CSHTML view that functions as a timeclock system for tracking user input against job numbers. The current Index.cshtml is operational, verifying JobNumbers against t ...

How can you determine the class of an element that was clicked within an iframe?

Is it possible to retrieve the class of an element that is clicked within an iframe? Here is the HTML code: <input id="tag" type="text"> <iframe id="framer" src="SameDomainSamePort.html"></iframe> This is the JavaScript code: $(docum ...

Ways to determine whether one side of a selected div is not obstructed by other divs

I am working with some div elements that are all sized 100x100px: Below is the HTML code for the 3 blocks: <div id="plane"> <div class="tile tile3" block-id="1" style-id="3" style="left:50px; top:50px"></div> <div class="tile t ...

What is the most effective method for managing Page Objects across diverse environments?

When dealing with multiple sites to support, such as US and Canada, some pages may be the same while others have different options. How can I utilize the page object pattern to define pages for this scenario and minimize redundancy? Let's consider th ...

Encountered a problem during the insertion of data into the database through ajax and php

An issue is being encountered while trying to insert data into a database using Ajax, PHP, and jQuery. The code works smoothly on a localhost environment, but upon uploading it to the server, an error occurs. $('#sunsubmit').click(function(){ ...

Enhance results by combining data from user input with data retrieved asynchronously from server-side APIs

In the process of developing a web application, I am facing a challenge. There is an input field where users can enter a number and next to it, I want to display the double of that number as the output. While this can be easily achieved using client-side J ...