Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Getting the ERROR "This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used." When I try to use restart() or close() method #5552

@Avijoy7

Description

@Avijoy7

Hi there!

I am trying to execute an extremely simple code. No page object, no method calling from different classes , no customizing configuration file. I am just trying to open a browser, then close it and then open a new browser instance.
#My Conf.js file is :

exports.config = {
  //directConnect: true,
  framework: 'jasmine2',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js']
}

#My spec file is:

const { browser, protractor } = require("protractor");
describe('abcd',  () => {
    it('Restart the browser', () => {
        browser.get('https://material.angular.io/')
        .then(()=>(browser.restart()))
        .then(()=>(browser.get('https://material.angular.io/')));
    });
       it ('2', async  () => {
        await browser.waitForAngularEnabled(false);
        await browser.get('https://www.google.com');
        await element(by.xpath("//input[@name='q']")).sendKeys('asdaf');
        await browser.close();
    });`
});

I want to close the browser after each It block and open a new instance of a browser in the next It block. I know that we can use restartAfterEachTest in the configuration file to restart browsers, but I am not looking for that, I want to close and open browsers from my Spec file.

If I use browser.restart() it shows me the is error "This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used." and the IT block is failed.

If I use browser.close() , the first It block is passing but all subsequent It blocks are getting failed immediately and the error is "Invalid Session ID".

Looking for a solution, thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions