简体   繁体   中英

protractor - after browser.restart basePage.js ref is lost

I am automating angularjs application which is based on basic authentication.

after every test i need to delete cookies and restart my browser so that i can login with different user.

To do this i am using browser.restart() method of protractor

However whenever i perform browser.restart(), my basePage.js references are lost and eventually i get 'This driver instance does not have a valid session ID'

my framework structure is as below

features
--feature1

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

step_definations
--step1.js

support
--world.js
--hooks.js

i am using

  1. cucumber-js
  2. javascript language
  3. POM
  4. protractor 5 version
  5. nodejs

After reading lots of posts, i got to know about reinitialize basePage.js in world.js so that its references are recreated. But i am not able to understand how to do this?

for session

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

If you found cookies is only issue try this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM