When the browser restarts, the reference to the basePage.js file is lost in Protractor

I'm currently automating an AngularJS application that uses basic authentication.

After each test, I need to delete cookies and restart my browser in order to login with a different user.

To achieve this, I am utilizing the browser.restart() method of Protractor.

However, every time I perform browser.restart(), I lose references to my basePage.js and eventually encounter the error message: 'This driver instance does not have a valid session ID'

The structure of my framework is as follows:

features
--feature1

pages
-page1.js
-page2.js
--basePage.js

step_definitions
--step1.js

support
--world.js
--hooks.js

I am using

  1. Cucumber-JS
  2. JavaScript language
  3. Page Object Model (POM)
  4. Protractor version 5
  5. Node.js

After researching various sources, I learned about reinitializing basePage.js in world.js so that its references are recreated. However, I'm struggling to understand how to do this?

Answer №1

Is your session giving you trouble?

browser.executeScript('window.sessionStorage.clear();

If the problem lies only with cookies, give this a try:

browser.driver.manage().deleteAllCookies(); 

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

JavaScript Ext is not declared

I've designed a webpage with tabs, and everything was working fine in our development environment. However, when we moved it to the staging environment, we started experiencing errors this morning that I'm not sure how to resolve as my JavaScript ...

Webpack failing to bundle JavaScript modules

I am trying to create a vanilla JS/bootstrap website using webpack, but despite following multiple tutorials and instructions, I can't seem to get it working. Here is the content of my webpack.config.js: const path = require('path') ...

Tips for utilizing Angular components alongside ui-router

I am attempting to utilize components (as opposed to controllers and templates) in ui-router. However, I am encountering issues with this approach. I am following the instructions provided in this article on their website. You can also view my code on ...

Access data from previous request and transmit it to another request in a Node.js environment

I am facing a situation where I need to extract the parsed json response from a variable in a POST request, store it in a new variable, and then pass that variable in the headers for a subsequent GET request. However, my current approach is not yielding th ...

Having trouble dividing an HTML file?

Currently, I am working on creating a very basic web page that is divided into two parts. Each part will have its own HTML file: Welcome.html & Welcome.css: <html> <head> <link rel="stylesheet" type="text/css" href="Welcom ...

Issue with updating state following data retrieval in React hooks

Recently, I've been experimenting with an API and working on a React application for data display. However, I encountered an issue while setting the state using the setState method of React Hooks after sending my information through a form request via ...

Restrict the number of GET requests made using D3.js and the Twitter API

Currently, I have made adjustments to my D3.js chart by switching from mouseover/mouseout events to mousemove. While this change has caused several issues in the chart, the most significant one pertains to my GET statuses/show/:id requests. In the past, h ...

Bootstrap form validation issues

Currently, I am utilizing Vue.js along with Bootstrap for the creation of a website. In this process, I have set up a form on which I am implementing my custom validation logic. Everything seems to be functioning correctly until the moment when the user hi ...

Tips for displaying error message popups to the right of the screen, rather than above it

I'm working with an HTML element that generates a popup. My goal is to display an error message in my form when the user inputs invalid data using this popup. However, I'm facing an issue where the popup appears on top of the form input, and ther ...

Guiding motion of a parental container using a button

This seems like a fairly straightforward task, but I'm getting a bit frustrated with it. Is there a way to move an entire div by simply holding down the mouse button on a particular button? let container = document.getElementById('abo ...

Using ThreeJS to project a texture onto a mesh surface

I am trying to project a texture onto the surface of a mesh using ThreeJS. The link provided achieves the desired result, although I am uncertain about the method used to accomplish it. . As I continue my research, I will update this post. If anyone has ...

Error: jQuery is unable to access the property 'xxx' because it is undefined

While attempting to make a post request from the site to the server with user input data, I encountered an error message saying TypeError: Cannot read property 'vehicle' of undefined as the response. Here is the HTML and script data: <!DOCTY ...

Dealing with errors in multer and express-validator aspects

Is there a way to validate a form that includes an image using multer and other fields with express-validator? I keep encountering an undefined error (req.validationError) in the post route. Any suggestions on how to resolve this issue? server.js const e ...

Utilize a directive to showcase information stored within the scope

Struggling to grasp the concept of directives and encountering a bug along the way. To see my example in action, check out the codepen I've created here In my scope called "movies," I have 3 movie titles that I want to display using a directive. va ...

Activate Bootstrap - navigate to a specific tab and scroll to a designated anchor upon link click

My goal is to switch to another tab and scroll to a specific part of the page after clicking on a link inside a tab. Unfortunately, although I have successfully switched tabs, I am unable to scroll down to the anchor point. I would greatly appreciate any ...

Guide: Using jQueryUI's explode effect to animate an HTML element explosion

I'm having trouble getting the jQueryUI explode effect to work properly. I've tested it out on this jsfiddle, but the explosion effect doesn't seem to happen as expected - the element just disappears with no explosion animation. $('h1, ...

How can I notify a particular user using Node.js?

This is the code I have for my server in the server.js file: var socket = require( 'socket.io' ); var express = require('express'); var app = express(); var server = require('http').createServer(app); var io = sock ...

Validation of forms in JavaScript, submission only occurs if the data is deemed to be

I am currently working on a JavaScript validation for a Perl form. The validation script is working correctly to display errors when data is missing. However, I am facing an issue where the form still submits after displaying the error messages. I believe ...

Retrieve the image source from a webview on an Android device

As I attempt to retrieve the source of a captcha image from a webview, I encounter an error message when running the below code: Uncaught TypeError: Cannot read property 'src' of null Furthermore, if I successfully obtain the image src, how can ...

Connect Tasks and Lists in Meteor Todo app

I'm currently developing a task management application using the Meteor tutorial as a reference. I have created lists based on the task model, but I am struggling to figure out how to connect them and display all tasks associated with a specific list ...