最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Protractor: Open new webdriver after every describe? - Stack Overflow

programmeradmin3浏览0评论

I need to open a new web driver after every describe (e2e test i run)

The reason is that i need to clear my browser cache (not cookies),

Every time i try to use ptor.quit() / browser.driver.quit(), i get this exception:

"Error: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used."

I need to open a new web driver after every describe (e2e test i run)

The reason is that i need to clear my browser cache (not cookies),

Every time i try to use ptor.quit() / browser.driver.quit(), i get this exception:

"Error: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used."

Share Improve this question edited Sep 5, 2015 at 9:38 giri-sh 6,9622 gold badges27 silver badges50 bronze badges asked Feb 2, 2014 at 15:25 friemanfrieman 312 silver badges4 bronze badges 2
  • 5 If you are testing on chrome, you could try to run it in incognito mode. capabilities: { 'browserName': 'chrome', 'chromeOptions': { 'args': ['incognito'] } } – gontard Commented Feb 3, 2014 at 8:58
  • 2 Careful if you need to take screenshots, etc. Incognito may block some functionality on account of the privacy features. – Wes Johnson Commented Dec 1, 2014 at 14:55
Add a ment  | 

2 Answers 2

Reset to default 3

You shouldn't start new webDriver session after each describe, but in turn use afterAll() functionality that Jasmine provides which runs after all specs in describe are finished running. In other words afterAll() runs after each describe and will suffice your need. Do not quit after all your specs are pleted in a describe as it stops the webdriver execution itself. Here's how to do it -

afterAll(function() {
    browser.executeScript('window.sessionStorage.clear();'); //clear session
    browser.executeScript('window.localStorage.clear();'); //clear local storage
});

May be you want to empty browser's local storage?

afterEach(function() {
    browser.executeScript('window.sessionStorage.clear();');
    browser.executeScript('window.localStorage.clear();');
});`
发布评论

评论列表(0)

  1. 暂无评论