nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.78k stars 1.31k forks source link

--suiteRetries is not working if a suite contains more than one test #3567

Closed ParvathyUKG closed 11 months ago

ParvathyUKG commented 1 year ago

Description of the bug/issue

When my suite has more than one test and has suiteRetries, I expect the tests to be re-executed. Instead, Nightwatch is throwing an error and reports the suite as passed

Retrying:  [Login suite] Test Suite (1/2): 
────────────────────────────────────────────────
ℹ Connected to ChromeDriver on port 9515 (1695ms).
  Using: chrome (108.0.5359.124) on MAC OS X.

  Running Verify home page header:
───────────────────────────────────────────────────────────────────────────────────────────────────
  ⠋ Loading url: http://www.google.com
    Error   Error while running .navigateTo() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
  ℹ Loaded url http://www.google.com in 1ms
No assertions ran.

  Running Verify home page header1:
───────────────────────────────────────────────────────────────────────────────────────────────────
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  ⠋ Loading url: http://www.google.com
    Error   Error while running .navigateTo() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
  ℹ Loaded url http://www.google.com in 1ms
No assertions ran.

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

  ✨ PASSED. 2 tests (17.507s)

Steps to reproduce

No response

Sample test

import { NightwatchTests, NightwatchBrowser } from 'nightwatch';
import { GooglePage } from '../page-objects/googlePage';

describe('Login suite', function() {
  const google: GooglePage = browser.page.googlePage();
  this.tags = ['login'];
  it('Verify home page header', function(browser) {
       google
      .navigate()
      .assert.titleEquals('Google')
      .assert.visible('@searchBar')
      .setValue('@searchBar', 'nightwatch');

    google
      .clickSearch()
      .expect.element('body')
      .text.to.contain(
        'Nightwatch.js1 | Node.js powered End-to-End testing framework');
  });

  it('Verify home page header1', function(browser) {
    google
   .navigate()
   .assert.titleEquals('Google')
   .assert.visible('@searchBar')
   .setValue('@searchBar', 'nightwatch');

 google
   .clickSearch()
   .expect.element('body')
   .text.to.contain(
     'Nightwatch.js1 | Node.js powered End-to-End testing framework');
});

  after(browser => {
    // browser.endSauce();
    browser.end();
  });
});

Command to run

tsc && nightwatch  --suiteRetries 2

Verbose Output

:pomTypeScriptExample hello$ npm run test

> nightwatch-typescript-page-object-model-example@1.0.0 test
> tsc && nightwatch  --suiteRetries 2  --verbose

 Now you can run TS tests directly using Nightwatch.

[Login suite] Test Suite
────────────────────────────────────────────────
⠋ Starting ChromeDriver on port 9515...
 Starting ChromeDriver with server_path=/Users/hello/Documents/test/nightwatchTutorials/pomTypeScriptExample/node_modules/chromedriver/lib/chromedriver/chromedriver...
   Request POST /session  
   {
     capabilities: {
       firstMatch: [ {} ],
       alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': {} }
     }
⠴ Starting ChromeDriver on port 9515...
   Response 200 POST /session (3612ms)
   {
     value: {
       capabilities: {
         acceptInsecureCerts: false,
         browserName: 'chrome',
         browserVersion: '108.0.5359.124',
         chrome: {
           chromedriverVersion: '108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016})',
           userDataDir: '/var/folders/yn/gg3fxdr51p184p980p9k_bcxtnxwdv/T/.com.google.Chrome.SHgOap'
         },
         'goog:chromeOptions': { debuggerAddress: 'localhost:50658' },
         networkConnectionEnabled: false,
         pageLoadStrategy: 'normal',
         platformName: 'mac os x',
         proxy: {},
         setWindowRect: true,
         strictFileInteractability: false,
         timeouts: { implicit: 0, pageLoad: 300000, script: 30000 },
         unhandledPromptBehavior: 'dismiss and notify',
         'webauthn:extension:credBlob': true,
         'webauthn:extension:largeBlob': true,
         'webauthn:virtualAuthenticators': true
       },
       sessionId: '7ae60e95d0f4d0101a5beb7cd413be9a'
     }
ℹ Connected to ChromeDriver on port 9515 (3703ms).
  Using: chrome (108.0.5359.124) on MAC OS X.

 Received session with ID: 7ae60e95d0f4d0101a5beb7cd413be9a

 → Running [before]:
 → Completed [before].

  Running Verify home page header:
───────────────────────────────────────────────────────────────────────────────────────────────────
 → Running [beforeEach]:
 → Completed [beforeEach].

 → Running command: url ('http://www.google.com', )
  ⠋ Loading url: http://www.google.com
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/url  
  ⠋ Loading url: http://www.google.com
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/url (1671ms)
  ℹ Loaded url http://www.google.com in 1673ms
  → Completed command: url ('http://www.google.com', ) (1675ms)

 → Running command: assert.titleEquals ('Google')

 → Running command: title ([Function])
   Request GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/title  

   Response 200 GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/title (5ms)
   { value: 'Google' }
  ✔ Testing if the page title equals 'Google' (7ms)
  → Completed command: title ([Function]) (7ms)
  → Completed command: assert.titleEquals ('Google') (12ms)

 → Running command: assert.visible ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...})

 → Running command: isVisible ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...}, [Function])
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements  
   { using: 'css selector', value: 'input[type=text]' }
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements (11ms)
   {
     value: [
       {
         'element-6066-11e4-a52e-4f735466cecf': '042245f5-2ae7-4c25-b3de-a7070def27d2'
       }
     ]
  }
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/execute/sync  
   {
     script: 'return (function(){return (function(){var k=this||self;function aa(a){return"string"==typeof a}function ba(a,b){a=a.split(".");var c=k;a[0]in c||"undefined"==typeof c.execScript||c.execScript("var "+a... (44027 characters)',
     args: [
       {
         'element-6066-11e4-a52e-4f735466cecf': '042245f5-2ae7-4c25-b3de-a7070def27d2',
         ELEMENT: '042245f5-2ae7-4c25-b3de-a7070def27d2'
       }
     ]
  }
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/execute/sync (14ms)
   { value: true }
  ✔ Testing if element <Element [name=@searchBar]> is visible (33ms)
  → Completed command: isVisible ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...}, [Function]) (31ms)
  → Completed command: assert.visible ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...}) (34ms)

 → Running command: setValue ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...}, 'nightwatch')
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements  
   { using: 'css selector', value: 'input[type=text]' }
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements (6ms)
   {
     value: [
       {
         'element-6066-11e4-a52e-4f735466cecf': '042245f5-2ae7-4c25-b3de-a7070def27d2'
       }
     ]
  }
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/042245f5-2ae7-4c25-b3de-a7070def27d2/clear  
{}
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/042245f5-2ae7-4c25-b3de-a7070def27d2/clear (32ms)
   { value: null }
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/042245f5-2ae7-4c25-b3de-a7070def27d2/value  
   {
     text: 'nightwatch',
     value: [
       'n', 'i', 'g', 'h',
       't', 'w', 'a', 't',
       'c', 'h'
     ]
  }
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/042245f5-2ae7-4c25-b3de-a7070def27d2/value (84ms)
   { value: null }
  → Completed command: setValue ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...}, 'nightwatch') (123ms)

 → Running command: waitForElementVisible ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...}, 10000)
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements  
   { using: 'css selector', value: 'input[name=btnK]' }
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements (11ms)
   {
     value: [
       {
         'element-6066-11e4-a52e-4f735466cecf': 'dc0d8aef-eaa8-48b4-99c2-96239f2d205f'
       },
       {
         'element-6066-11e4-a52e-4f735466cecf': '4e9706d3-2167-48eb-b11f-516ab3d60b10'
       }
     ]
  }
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/execute/sync  
   {
     script: 'return (function(){return (function(){var k=this||self;function aa(a){return"string"==typeof a}function ba(a,b){a=a.split(".");var c=k;a[0]in c||"undefined"==typeof c.execScript||c.execScript("var "+a... (44027 characters)',
     args: [
       {
         'element-6066-11e4-a52e-4f735466cecf': 'dc0d8aef-eaa8-48b4-99c2-96239f2d205f',
         ELEMENT: 'dc0d8aef-eaa8-48b4-99c2-96239f2d205f'
       }
     ]
  }
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/execute/sync (11ms)
   { value: false }
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/execute/sync  
   {
     script: 'return (function(){return (function(){var k=this||self;function aa(a){return"string"==typeof a}function ba(a,b){a=a.split(".");var c=k;a[0]in c||"undefined"==typeof c.execScript||c.execScript("var "+a... (44027 characters)',
     args: [
       {
         'element-6066-11e4-a52e-4f735466cecf': 'dc0d8aef-eaa8-48b4-99c2-96239f2d205f',
         ELEMENT: 'dc0d8aef-eaa8-48b4-99c2-96239f2d205f'
       }
     ]
  }
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/execute/sync (8ms)
   { value: true }
  ✔ Element <input[name=btnK]> was visible after 534 milliseconds.
  → Completed command: waitForElementVisible ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...}, 10000) (535ms)

 → Running command: click ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...})
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements  
   { using: 'css selector', value: 'input[name=btnK]' }
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements (6ms)
   {
     value: [
       {
         'element-6066-11e4-a52e-4f735466cecf': 'dc0d8aef-eaa8-48b4-99c2-96239f2d205f'
       },
       {
         'element-6066-11e4-a52e-4f735466cecf': '4e9706d3-2167-48eb-b11f-516ab3d60b10'
       }
     ]
  }
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/dc0d8aef-eaa8-48b4-99c2-96239f2d205f/click  
{}
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/dc0d8aef-eaa8-48b4-99c2-96239f2d205f/click (2802ms)
   { value: null }
  → Completed command: click ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...}) (2810ms)

 → Running command: waitForElementNotPresent ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...})
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements  
   { using: 'css selector', value: 'input[name=btnK]' }
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements (7ms)
   { value: [] }
  ✔ Element <input[name=btnK]> was not present after 9 milliseconds.
  → Completed command: waitForElementNotPresent ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...}) (9ms)

 → Running command: expect.element ('body')
   Request POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements  
   { using: 'css selector', value: 'body' }
   Response 200 POST /session/7ae60e95d0f4d0101a5beb7cd413be9a/elements (9ms)
   {
     value: [
       {
         'element-6066-11e4-a52e-4f735466cecf': '5193e251-e366-44c0-9299-14978215a3e4'
       }
     ]
  }
   Request GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text  

   Response 200 GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text (453ms)
   {
     value: 'Accessibility Links\n' +
       'Skip to main content\n' +
       'Switch to page by page results\n' +
       'Accessibility help\n' +
       'Accessibi...',
     suppressBase64Data: true
  }
   Request GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text  

   Response 200 GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text (288ms)
   {
     value: 'Accessibility Links\n' +
       'Skip to main content\n' +
       'Switch to page by page results\n' +
       'Accessibility help\n' +
       'Accessibi...',
     suppressBase64Data: true
  }
   Request GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text  

   Response 200 GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text (277ms)
   {
     value: 'Accessibility Links\n' +
       'Skip to main content\n' +
       'Switch to page by page results\n' +
       'Accessibility help\n' +
       'Accessibi...',
     suppressBase64Data: true
  }
   Request GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text  

   Response 200 GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text (314ms)
   {
     value: 'Accessibility Links\n' +
       'Skip to main content\n' +
       'Switch to page by page results\n' +
       'Accessibility help\n' +
       'Accessibi...',
     suppressBase64Data: true
  }
   Request GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text  

   Response 200 GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text (277ms)
   {
     value: 'Accessibility Links\n' +
       'Skip to main content\n' +
       'Switch to page by page results\n' +
       'Accessibility help\n' +
       'Accessibi...',
     suppressBase64Data: true
  }
   Request GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text  

   Response 200 GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text (275ms)
   {
     value: 'Accessibility Links\n' +
       'Skip to main content\n' +
       'Switch to page by page results\n' +
       'Accessibility help\n' +
       'Accessibi...',
     suppressBase64Data: true
  }
   Request GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text  

   Response 200 GET /session/7ae60e95d0f4d0101a5beb7cd413be9a/element/5193e251-e366-44c0-9299-14978215a3e4/text (262ms)
   {
     value: 'Accessibility Links\n' +
       'Skip to main content\n' +
       'Switch to page by page results\n' +
       'Accessibility help\n' +
       'Accessibi...',
     suppressBase64Data: true
  }
  ✖ NightwatchAssertError
   Expected element <body> text to contain: "Nightwatch.js1 | Node.js powered End-to-End testing framework" - expected "contain 'Nightwatch.js1 | Node.js powered End-to-End testing framework'" but got: "Accessibility Links
Skip to main content
Switch to page by page results
Accessibility help
Accessibility feedback
Sign in
Search Modes
All
Videos
News
Images
Shopping
More
Tools
About 17,500,000 results (0.41 seconds) 
Search Results

Watch Nightwatch Full Episodes, Video & More - A&E
https://www.aetv.com › shows › nightwatch
“Nightwatch” chronicles the sacrifice and heroic work of the first responders in New Orleans, a singular city filled with rich culture and a vibrant ...
People also ask
Is Nightwatch coming back in 2022?

Is Nightwatch still being filmed?

Where can I watch Nightwatch 2022?

Is the Nightwatch show real?

Where is Dan from Nightwatch now?

Do they still film Nightwatch in New Orleans?

Feedback

Watch Nightwatch Streaming Online | Hulu (Free Trial)
https://www.hulu.com › series › nightwatch-f20f68f8-8...
Start your free trial to watch Nightwatch and other popular TV shows and movies including new releases, classics, Hulu Originals, and more.

Nightwatch (TV Series 2015– ) - IMDb
https://www.imdb.com › title
Follow the men and women who keep the citizens of New Orleans safe during the night. Ride along with the police officers, the firefighters, ...
Rating: 8.8/10 · 998 votes

Nightwatch (TV series) - Wikipedia
https://en.wikipedia.org › wiki › Nightwatch_(TV_series)
Nightwatch is an American reality television series broadcast by A&E. ... The show follows the night-shift emergency service workers of a specific city as they ...
Original release: January 22, 2015 –; present
Original network: A&E
No. of seasons: 6
Production company: 44 Blue Productions
List of episodes · Season 1 (2015) · Season 4 (2017) · Reception

Nightwatch.js | Node.js powered End-to-End testing framework
https://nightwatchjs.org
From set up to test execution and debugging, Nightwatch simplifies test automation for you. Get started in 60 seconds and see it in action.

Nightwatch - Home - Facebook
https://www.facebook.com › ... › TV show
Nightwatch. 232845 likes · 7979 talking about this. Official Nightwatch page Twitter @AETV | Instagram @AETV http://www.aetv.com/shows/nightwatch.

Nightwatch: Most Viewed Moments of 2022 | A&E - YouTube
https://www.youtube.com › watch
1:37:37
Check out the most-viewed moments of 2022, in this compilation from Nightwatch!Watch the latest clips from Nightwatch here: ...
YouTube · A&E · 1 month ago

Nightwatch: NEVER BEFORE SEEN MEGA-Compilation | A&E
https://www.youtube.com › watch
53:44
Bring out the popcorn and watch this NEVER BEFORE SEEN mega-compilation of Nightwatch bonus scenes!Watch the latest clips from  ...
YouTube · A&E · Mar 18, 2022
8 key moments in this video
Related searches
nightwatch movie
nightwatch season 7
nightwatch youtube
nightwatch netflix
nightwatch wiki
nightwatch season 6
nightwatch season 5
nightwatch book
More results
Complementary Results
Nightwatch
2015 ‧ Reality ‧ 6 seasons
Images
More images
Watch now
Free
Already watched
Want to watch
All watch options
8.8/10 · IMDb
86% liked this TV show
Google users
Description
The old saying "Nothing good happens after midnight" rings true in the nonfiction series "Nightwatch." Hourlong episodes follow emergency responders in New Orleans and Tampa, Fla., who work the busy, unpredictable 8 p.m. to 4 a.m. shift, battling time and circumstances while attempting to save lives… MORE
Network: A&E Network
First episode date: January 22, 2015
Created by: Dick Wolf
Episode guide
S6 E9 · Why We Serve
May 5, 2022
S6 E8 · Saturday Night Fever Dream
Apr 28, 2022
S6 E7 · Lifeline
Apr 21, 2022
Cast
Dan Flynn
Nick Manning
Holly Monteleone
Titus Tero
Reviews
Audience rating summary
4.7
120 ratings
Audience reviews
This show is 100% tone deaf. EMS in NOLA is abused. The show producers have the power and the voice to change that, but they ...
I stumbled upon this show on Hulu and decided to watch it just because. I instantly fell in love with it. I hate that Hulu doesn't have ...
People also search for
Rescue Cam
Since 2020
Durban Beach Rescue
Since 2015
Bare Hands Rescue
Since 2021
Nightwatch Nation
2018
More about Nightwatch
Report or send feedback" (5172ms)

    Error location:
    /Users/hello/Documents/test/nightwatchTutorials/pomTypeScriptExample/distrib/src/tests/googleTest.js:
    ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
     12 |         google
     13 |             .clickSearch()
     14 |             .expect.element('body') 
     15 |             .text.to.contain('Nightwatch.js1 | Node.js powered End-to-End testing framework');
     16 |     });
    ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

  → Completed command: expect.element ('body') (5175ms)
 → Running [afterEach]:
 → Completed [afterEach].

  FAILED: 1 assertions failed and  4 passed (10.442s)
 → Running [after]:

 → Running command: end ()

 → Running command: session ('delete', [Function])
   Request DELETE /session/7ae60e95d0f4d0101a5beb7cd413be9a  

   Response 200 DELETE /session/7ae60e95d0f4d0101a5beb7cd413be9a (53ms)
   { value: null }
  → Completed command: session ('delete', [Function]) (54ms)
 Wrote log file to: /Users/hello/Documents/test/nightwatchTutorials/pomTypeScriptExample/logs/googleTest_chromedriver.log
  → Completed command: end () (61ms)
 → Completed [after].

Retrying:  [Login suite] Test Suite (1/2): 
────────────────────────────────────────────────
⠋ Starting ChromeDriver on port 9515...
 Starting ChromeDriver with server_path=/Users/hello/Documents/test/nightwatchTutorials/pomTypeScriptExample/node_modules/chromedriver/lib/chromedriver/chromedriver...
 ChromeDriver process closed.
   Request POST /session  
   {
     capabilities: {
       firstMatch: [ {} ],
       alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': {} }
     }
⠹ Starting ChromeDriver on port 9515...
   Response 200 POST /session (1754ms)
   {
     value: {
       capabilities: {
         acceptInsecureCerts: false,
         browserName: 'chrome',
         browserVersion: '108.0.5359.124',
         chrome: {
           chromedriverVersion: '108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016})',
           userDataDir: '/var/folders/yn/gg3fxdr51p184p980p9k_bcxtnxwdv/T/.com.google.Chrome.3nIxG7'
         },
         'goog:chromeOptions': { debuggerAddress: 'localhost:50795' },
         networkConnectionEnabled: false,
         pageLoadStrategy: 'normal',
         platformName: 'mac os x',
         proxy: {},
         setWindowRect: true,
         strictFileInteractability: false,
         timeouts: { implicit: 0, pageLoad: 300000, script: 30000 },
         unhandledPromptBehavior: 'dismiss and notify',
         'webauthn:extension:credBlob': true,
         'webauthn:extension:largeBlob': true,
         'webauthn:virtualAuthenticators': true
       },
       sessionId: '4eba5826f7d9a4cce1689e33ea735a53'
     }
ℹ Connected to ChromeDriver on port 9515 (1795ms).
  Using: chrome (108.0.5359.124) on MAC OS X.

 Received session with ID: 4eba5826f7d9a4cce1689e33ea735a53

 → Running [before]:
 → Completed [before].

  Running Verify home page header:
───────────────────────────────────────────────────────────────────────────────────────────────────
 → Running [beforeEach]:
 → Completed [beforeEach].

 → Running command: url ('http://www.google.com', )
  ⠋ Loading url: http://www.google.com
    Error   Error while running .navigateTo() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
  ℹ Loaded url http://www.google.com in 1ms
  → Completed command: url ('http://www.google.com', ) (1ms)

 → Running command: assert.titleEquals ('Google')
 → Running [afterEach]:
 → Completed [afterEach].
No assertions ran.

  Running Verify home page header1:
───────────────────────────────────────────────────────────────────────────────────────────────────
 → Running [beforeEach]:
 → Completed [beforeEach].

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (1ms)

 → Running command: url ('http://www.google.com', )
  ⠋ Loading url: http://www.google.com
    Error   Error while running .navigateTo() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
  ℹ Loaded url http://www.google.com in 0ms
  → Completed command: url ('http://www.google.com', ) (0ms)

 → Running command: assert.titleEquals ('Google')
 → Running [afterEach]:
 → Completed [afterEach].
No assertions ran.

 → Running [after]:

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (0ms)

 → Running command: end ()

 → Running command: session ('delete', [Function])
   Request DELETE /session/4eba5826f7d9a4cce1689e33ea735a53  

   Response 200 DELETE /session/4eba5826f7d9a4cce1689e33ea735a53 (54ms)
   { value: null }
  → Completed command: session ('delete', [Function]) (55ms)
 Wrote log file to: /Users/hello/Documents/test/nightwatchTutorials/pomTypeScriptExample/logs/googleTest_chromedriver.log
  → Completed command: end () (56ms)
 → Completed [after].

  ✨ PASSED. 2 tests (16.852s)
 ChromeDriver process closed.
 Wrote HTML report file to: /Users/hello/Documents/test/nightwatchTutorials/pomTypeScriptExample/tests_output/nightwatch-html-report/index.html

 Wrote JSON report file to: /Users/hello/Documents/test/nightwatchTutorials/pomTypeScriptExample/tests_output/CHROME_108.0.5359.124__googleTest.json
 Wrote XML report file to: /Users/hello/Documents/test/nightwatchTutorials/pomTypeScriptExample/tests_output/CHROME_108.0.5359.124__googleTest.xml

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (1ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (0ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (1ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (0ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (1ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (0ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (0ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (1ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (1ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (0ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (1ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (0ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (0ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (1ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (1ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (0ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (0ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  → Completed command: title ([Function]) (1ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  ✖ NightwatchAssertError
   Testing if the page title equals 'Google' in 5000ms - expected "is 'Google'" but got: "" (5038ms)

    Error location:
    /Users/hello/Documents/test/nightwatchTutorials/pomTypeScriptExample/distrib/src/tests/googleTest.js:
    ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
     7 |         google
     8 |             .navigate()
     9 |             .assert.titleEquals('Google') 
     10 |             .assert.visible('@searchBar')
     11 |             .setValue('@searchBar', 'nightwatch');
    ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

  → Completed command: title ([Function]) (6ms)

 → Running command: title ([Function])
    Error   Error while running .getPageTitle() protocol action: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

  ✖ NightwatchAssertError
   Testing if the page title equals 'Google' in 5000ms - expected "is 'Google'" but got: "" (5037ms)

    Error location:
    /Users/hello/Documents/test/nightwatchTutorials/pomTypeScriptExample/distrib/src/tests/googleTest.js:
    ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
     18 |         google
     19 |             .navigate()
     20 |             .assert.titleEquals('Google') 
     21 |             .assert.visible('@searchBar')
     22 |             .setValue('@searchBar', 'nightwatch');
    ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

  → Completed command: title ([Function]) (2ms)
  → Completed command: assert.titleEquals ('Google') (5045ms)
  → Completed command: assert.titleEquals ('Google') (5040ms)

Nightwatch Configuration

//
// Refer to the online docs for more details:
// https://nightwatchjs.org/gettingstarted/configuration/
//
//  _   _  _         _      _                     _          _
// | \ | |(_)       | |    | |                   | |        | |
// |  \| | _   __ _ | |__  | |_ __      __  __ _ | |_   ___ | |__
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
// | |\  || || (_| || | | || |_  \ V  V / | (_| || |_ | (__ | | | |
// \_| \_/|_| \__, ||_| |_| \__|  \_/\_/   \__,_| \__| \___||_| |_|
//             __/ |
//            |___/
//

module.exports = {
  // An array of folders (excluding subfolders) where your tests are located;
  // if this is not specified, the test source must be passed as the second argument to the test runner.
  src_folders: ['./distrib/src/tests'],

  // See https://nightwatchjs.org/guide/working-with-page-objects/using-page-objects.html
  page_objects_path: ['./distrib/src/page-objects'],

  // See https://nightwatchjs.org/guide/extending-nightwatch/custom-assertions.html
  custom_assertions_path: '',

  // See https://nightwatchjs.org/guide/extending-nightwatch/plugin-api.html
  plugins: [],

  // See https://nightwatchjs.org/guide/#external-globals
  globals_path: '',

  webdriver: {},

  test_settings: {
    default: {
      disable_error_log: false,
      launch_url: 'https://nightwatchjs.org',

      screenshots: {
        enabled: false,
        path: 'screens',
        on_failure: true,
      },

      desiredCapabilities: {
        browserName: 'chrome',
      },

      webdriver: {
        start_process: true,
        server_path: '',
      },
    },

    firefox: {
      desiredCapabilities: {
        browserName: 'firefox',
        alwaysMatch: {
          acceptInsecureCerts: true,
          'moz:firefoxOptions': {
            args: [
              // '-headless',
              // '-verbose'
            ],
          },
        },
      },
      webdriver: {
        start_process: true,
        server_path: '',
        cli_args: [
          // very verbose geckodriver logs
          // '-vv'
        ],
      },
    },

    chrome: {
      desiredCapabilities: {
        browserName: 'chrome',
        'goog:chromeOptions': {
          // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
          //
          // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
          w3c: true,
          args: [
            //'--no-sandbox',
            //'--ignore-certificate-errors',
            //'--allow-insecure-localhost',
            //'--headless'
          ],
        },
      },

      webdriver: {
        start_process: true,
        server_path: '',
        cli_args: [
          // --verbose
        ],
      },
    },

    edge: {
      desiredCapabilities: {
        browserName: 'MicrosoftEdge',
        'ms:edgeOptions': {
          w3c: true,
          // More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options
          args: [
            //'--headless'
          ],
        },
      },

      webdriver: {
        start_process: true,
        // Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/
        //  and set the location below:
        server_path: '',
        cli_args: [
          // --verbose
        ],
      },
    },

    //////////////////////////////////////////////////////////////////////////////////
    // Configuration for when using cucumber-js (https://cucumber.io)                |
    //                                                                               |
    // It uses the bundled examples inside the nightwatch examples folder; feel free |
    // to adapt this to your own project needs                                       |
    //////////////////////////////////////////////////////////////////////////////////
    'cucumber-js': {
      src_folders: ['examples/cucumber-js/features/step_definitions'],

      test_runner: {
        // set cucumber as the runner
        type: 'cucumber',

        // define cucumber specific options
        options: {
          //set the feature path
          feature_path:
            'node_modules/nightwatch/examples/cucumber-js/*/*.feature',

          // start the webdriver session automatically (enabled by default)
          // auto_start_session: true

          // use parallel execution in Cucumber
          // parallel: 2 // set number of workers to use (can also be defined in the cli as --parallel 2
        },
      },
    },

    //////////////////////////////////////////////////////////////////////////////////
    // Configuration for when using the browserstack.com cloud service               |
    //                                                                               |
    // Please set the username and access key by setting the environment variables:  |
    // - BROWSERSTACK_USER                                                           |
    // - BROWSERSTACK_KEY                                                            |
    // .env files are supported                                                      |
    //////////////////////////////////////////////////////////////////////////////////
    browserstack: {
      selenium: {
        host: 'hub-cloud.browserstack.com',
        port: 443,
      },
      // More info on configuring capabilities can be found on:
      // https://www.browserstack.com/automate/capabilities?tag=selenium-4
      desiredCapabilities: {
        'bstack:options': {
          userName: '${BROWSERSTACK_USER}',
          accessKey: '${BROWSERSTACK_KEY}',
        },
      },

      disable_error_log: true,
      webdriver: {
        timeout_options: {
          timeout: 15000,
          retry_attempts: 3,
        },
        keep_alive: true,
        start_process: false,
      },
    },

    'browserstack.local': {
      extends: 'browserstack',
      desiredCapabilities: {
        'browserstack.local': true,
      },
    },

    'browserstack.chrome': {
      extends: 'browserstack',
      desiredCapabilities: {
        browserName: 'chrome',
        chromeOptions: {
          w3c: true,
        },
      },
    },

    'browserstack.firefox': {
      extends: 'browserstack',
      desiredCapabilities: {
        browserName: 'firefox',
      },
    },

    'browserstack.ie': {
      extends: 'browserstack',
      desiredCapabilities: {
        browserName: 'internet explorer',
        browserVersion: '11.0',
      },
    },

    'browserstack.safari': {
      extends: 'browserstack',
      desiredCapabilities: {
        browserName: 'safari',
      },
    },

    'browserstack.local_chrome': {
      extends: 'browserstack.local',
      desiredCapabilities: {
        browserName: 'chrome',
      },
    },

    'browserstack.local_firefox': {
      extends: 'browserstack.local',
      desiredCapabilities: {
        browserName: 'firefox',
      },
    },
    //////////////////////////////////////////////////////////////////////////////////
    // Configuration for when using the Selenium service, either locally or remote,  |
    //  like Selenium Grid                                                           |
    //////////////////////////////////////////////////////////////////////////////////
    selenium_server: {
      // Selenium Server is running locally and is managed by Nightwatch
      // Install the NPM package @nightwatch/selenium-server or download the selenium server jar file from https://github.com/SeleniumHQ/selenium/releases/, e.g.: selenium-server-4.1.1.jar
      selenium: {
        start_process: true,
        port: 4444,
        server_path: '', // Leave empty if @nightwatch/selenium-server is installed
        command: 'standalone', // Selenium 4 only
        cli_args: {
          //'webdriver.gecko.driver': '',
          //'webdriver.chrome.driver': ''
        },
      },
      webdriver: {
        start_process: false,
        default_path_prefix: '/wd/hub',
      },
    },

    'selenium.chrome': {
      extends: 'selenium_server',
      desiredCapabilities: {
        browserName: 'chrome',
        chromeOptions: {
          w3c: true,
        },
      },
    },

    'selenium.firefox': {
      extends: 'selenium_server',
      desiredCapabilities: {
        browserName: 'firefox',
        'moz:firefoxOptions': {
          args: [
            // '-headless',
            // '-verbose'
          ],
        },
      },
    },
  },
};

Nightwatch.js Version

2.6.1

Node Version

v14.15.1

Browser

Chrome 108

Operating System

MAC Monterey

Additional Information

The sample repo attached pomTypeScriptExample.zip

AutomatedTester commented 1 year ago

I think we aren't cleaning up the selenium session and then starting a new one which means we are reusing a Selenium object and that session has been closed (see the DELETE /session/<session id> in the logs above.)

gravityvi commented 1 year ago

@ParvathyUKG I am not able to reproduce this with our latest nightwatch version v3.1.3. Are you still facing this issue?

AutomatedTester commented 11 months ago

Closing as info not provided