The occurrence of multiple URLs being passed to driver.get can lead to inaccurate test

As I embark on creating a system with an expanding assortment of single-page applications, I am exploring strategies to efficiently organize their UI tests. My current approach involves writing a test module for each page in order to validate it thoroughly. However, I have encountered difficulties when trying to execute driver.get() consecutively.

The code below shows the structure of the project:

var webdriver = require('selenium-webdriver');
var test = require('selenium-webdriver/testing');
var expect = require('chai').expect;
var server = new require('selenium-webdriver/remote').SeleniumServer(path, {port: 4444});
var specs = [
    require('./google'), require('./bing')
];

//...

var driver = new webdriver.Builder()
         .usingServer(server.address())
         .withCapabilities(webdriver.Capabilities.firefox())
         .build();

test.describe('while learning webdriverjs', function() {
    test.after(function() {
        driver.quit();
    });

    specs.forEach(function(spec) {
        spec.run(driver, webdriver, test);
    });
});

The 'bing.js' file contains the following:

var expect = require('chai').expect;

function run(browser, webdriver, test) {
    test.describe('a trip to bing', function() {
        browser.get('http://www.bing.com');

        test.it('does not fail', function() {
            browser.getTitle().then(function(title) {
               expect(title).to.equal('Bing');
            });
        });
    });
}

module.exports = { run: run };

Similarly, the 'google.js' file is structured as follows:

var expect = require('chai').expect;

function run(browser, webdriver, test) {
    test.describe('a trip to google', function() {
        browser.get('http://www.google.com');

        test.it('does not fail', function() {
            browser.getTitle().then(function(title) {
                expect(title).to.equal('Google');
            });
        });
    });
}

module.exports = { run: run };

While running either 'google.js' or 'bing.js' individually works fine, executing them sequentially results in the following error message:

Error Message Here
Detailed stack trace here.

I'm currently troubleshooting why invoking driver.get() seems to be faster than the execution of the tests themselves. Additionally, I've tried using the done() method to conclude asynchronous tests, but encountered issues due to its unavailability in selenium-webdriver/testing (resulting in an "undefined is not a function" error).

Experimenting without utilizing the selenium-wrapped Mocha globals provided unexpected outcomes - on my Windows machine, all tests pass immediately before launching the browser instance, whereas on Ubuntu, the tests also pass prematurely without loading the browser at all.

Despite these challenges, I believe there are alternative methods to organize and execute these tests effectively, even though I may not see them clearly at the moment.

Answer №1

It appears that your tests are being run concurrently, but you seem to be using the same instance of the driver for each test, resulting in them sharing the same browser window.

There also seems to be some confusion in how you're utilizing the webdriverjs testing functionalities. If there is a test.describe(...), I would expect to see a corresponding test.it(...).

You may want to refer to one of the test files in Web Driver to see how they structure their tests.

Answer №2

After some contemplation, I ultimately chose to utilize protractor.

The root of my problem was mainly due to lack of organization, and protractor seems to provide the resolution.

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

Manipulating Objects and Arrays

When I retrieve data from a database query in Node.js using Postgres with Knex, I get an array of objects structured like this: (condensed version) [ { tvshow: 'house', airdate: 2017-02-01T00:00:00.000Z }, { tvshow: ' ...

A custom class that uses toggleClass() does not trigger an alert upon a click event

I am encountering an issue with the toggleClass() function in jQuery that I haven't seen addressed before. Despite successfully toggling the class of one button when clicked, I am unable to trigger a click event on the newly toggled class. Here is th ...

extracting and interpreting JSON information from a socket using Node.js

Looking for a solution to buffer JSON data received from client(s) on my node.js net tcp server until the entire block arrives. I'm considering either parsing it or forwarding it elsewhere. Are there any modules out there that are compatible with the ...

Having trouble with clicking checkboxes in Python using Selenium, receiving the error message "selenium.common.exceptions.ElementClickInterceptedException"

When attempting to click on a checkbox on a webpage, I encountered the following error message. Can anyone provide suggestions? The error received is: selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element ...

Storing the file name in a database with Node.js

Seeking assistance with a project idea - Is it feasible to develop an application that can scan a directory for all .txt files, extract the filenames, and store them in a database while ensuring no duplicates are saved? Below is the code snippet I have be ...

Mastering the Art of Dynamically Assigning Types in TypeScript

Recently, I encountered a challenge with wrapper function types. I am looking to convert functions with callbacks into promise-based functions. Most of these functions have a similar structure: func({ success:...., fail:...., complete:... }) So, I ...

Looking for a way to locate the previous sorted element in jQuery?

<div id="con" > <p class="bb">1</p> <p class="aa">2</p> <p class="aa">3</p> <p class="bb">4</p> /*----- i need to reference this */ <p class="aa">5</p> <p class="a ...

The state returned by React Redux does not meet the expected results

I recently implemented a like function on the backend using Node and MongoDB. This function successfully returns the post with an updated likes counter, which I tested using Postman. The post object contains properties such as likes, _id, by, createdAt, an ...

"Enhancing User Experience with AngularJS by Dynamically Modifying and Refresh

I'm currently attempting to dynamically add HTML elements using JavaScript with a directive: document.getElementsByClassName("day-grid")[0].innerHTML = "<div ng-uc-day-event></div>"; or var ele = document.createElement("div"); ele.setAttr ...

Secure a RESTful API with a Keycloak access token in a Node.js environment

I have implemented a REST API in Node.js and integrated the keycloak-connect npm package for security. I have configured the Node.js middleware to work with the keycloak middleware. var express = require('express'); var router = express.Router(); ...

Implementing interactive dropdown menus to trigger specific actions

I have modified some code I found in a tutorial on creating hoverable dropdowns from W3. Instead of the default behavior where clicking on a link takes you to another page, I want to pass a value to a function when a user clicks. Below is a snippet of the ...

Automatically Populate Text Field with the URL of the Current Page

I am hoping to automatically fill a hidden text field with the URL of the current page so that I can keep track of where form submissions are coming from. This simple solution will help me streamline my inquiry responses and save time. To clarify, upon lo ...

When trying to use npm install, the process is being interrupted by receiving both 304 and 404

Whenever I execute the npm install command, my console floods with this: npm http fetch GET 304 http://registry.npmjs.org/is-arrayish 60ms (from cache) npm http fetch GET 304 http://registry.npmjs.org/spdx-license-ids 67ms (from cache) npm http fetch GET ...

What could be causing the lack of value appearing after I clicked the button?

Setting the value for the array of images as an empty string does not return the expected result. When I move one of the 4 images and click the button, I anticipate a new array with the information of one of the four images including src, x, and y coordina ...

Detecting when an object exits the proximity of another object in ThreeJS

In my ThreeJS project, I have planes (Object3D) flying inside a sphere (Mesh). My goal is to detect when a plane collides with the border of the sphere so that I can remove it and respawn it in a different location within the sphere. I am wondering how I ...

"Enhance your gaming experience with Three JS special effects

I'm in the process of creating a multiplayer web game using Three JS. So far, I have successfully implemented the game logic on both client and server sides, mesh imports, animations, skill bars, health bars, and the ability for players to engage in c ...

Obtaining hyperlinks to encircle the sound button

Code 1: If you notice, after clicking on the image, the audio button appears and plays without any surrounding links. How can I enable the links around the audio button in Code 1? https://jsfiddle.net/7ux1s23j/29/ https://i.sstatic.net/75wlN.png < ...

How to dynamically add an input textbox after a selection change in YUI JavaScript?

Is there a way to add an extra input textbox after an onchange event in a selectbox using the YUI library? I need to utilize YUI and the form is generated with PEAR Quickforms lib. This is what I have so far: $form->addElement('select', &ap ...

Access-Control-Allow-Headers does not allow the use of X-Requested-With

I'm currently working on a system that includes an add item to cart feature. This functionality involves using Jquery's $.ajax method. However, I've encountered an error when attempting to access the online server - "XMLHttpRequest canno ...

Having trouble getting HTML to render properly in React JS on localhost using Apache server

For the past week, I've been working on resolving an issue. I started by creating a React Application using: npm create react-app After that, I attempted to build it with: npm run build Everything seemed to go smoothly. I generated a build folder ...