Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDP does not reset the connection after a test session ends #3455

Closed
LeoWie93 opened this issue Oct 27, 2022 · 8 comments · Fixed by #3593
Closed

CDP does not reset the connection after a test session ends #3455

LeoWie93 opened this issue Oct 27, 2022 · 8 comments · Fixed by #3593
Assignees

Comments

@LeoWie93
Copy link

LeoWie93 commented Oct 27, 2022

Description of the bug/issue

When running multiple test suits each using registerBasicAuth, only the first test suit works.

Steps to reproduce

  1. use registerBasicAuth in 2 different test files
  2. run all test files with nightwatch

Sample test

## Test File 1
describe('1: Test basic auth', function () {

    test('First', function (browser) {
        browser
            .registerBasicAuth('user', 'pass')
            .navigateTo('https://example.ch')
            .pause(4000)
            .assert.titleContains('Title');
    });

    test('First Another', function (browser) {
        browser
            .navigateTo('https://example.ch/underpage')
            .pause(4000)
            .waitForElementVisible('body');
    });
});

## Test File 2
describe('2: Test basic auth', function () {

    test('Second', function (browser) {
        browser
            .registerBasicAuth('user', 'pass')
            .navigateTo('https://example.ch/contact')
            .pause(4000)
            .assert.titleContains('contact');
    });

    test('Second Another', function (browser) {
        browser
            .navigateTo('https://example/events')
            .pause(4000)
            .waitForElementVisible('body');
    });
});

Command to run

npx nightwatch ./basic-auth

Verbose Output

[2: Test basic auth] Test Suite
──────────────────────────────────────────────────────────────
⠋ Starting ChromeDriver on port 9515...
 Starting ChromeDriver with server_path=<project-path>/node_modules/chromedriver/lib/chromedriver/chromedriver...
 ChromeDriver process closed.
   Request POST /session  
   {
     desiredCapabilities: {
       browserName: 'chrome',
       'goog:chromeOptions': { w3c: false, args: [ '--no-sandbox', '--window-size=1920,1080' ] },
       name: '2: Test basic auth'
     },
     capabilities: {
       alwaysMatch: {
         browserName: 'chrome',
         'goog:chromeOptions': {
           w3c: false,
           args: [ '--no-sandbox', '--window-size=1920,1080' ]
         }
       }
     }
⠧ Starting ChromeDriver on port 9515...
   Response 200 POST /session (584ms)
   {
     sessionId: '6af5e2832229e552b0394eac92f88181',
     status: 0,
     value: {
       acceptInsecureCerts: false,
       acceptSslCerts: false,
       browserConnectionEnabled: false,
       browserName: 'chrome',
       chrome: {
         chromedriverVersion: '106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249@{#569})',
         userDataDir: '/tmp/.com.google.Chrome.2bdBqR'
       },
       cssSelectorsEnabled: true,
       databaseEnabled: false,
       'goog:chromeOptions': { debuggerAddress: 'localhost:34971' },
       handlesAlerts: true,
       hasTouchScreen: false,
       javascriptEnabled: true,
       locationContextEnabled: true,
       mobileEmulationEnabled: false,
       nativeEvents: true,
       networkConnectionEnabled: false,
       pageLoadStrategy: 'normal',
       platform: 'Linux',
       proxy: {},
       rotatable: false,
       setWindowRect: true,
       strictFileInteractability: false,
       takesHeapSnapshot: true,
       takesScreenshot: true,
       timeouts: { implicit: 0, pageLoad: 300000, script: 30000 },
       unexpectedAlertBehaviour: 'ignore',
       version: '107.0.5304.68',
       webStorageEnabled: true,
       'webauthn:extension:credBlob': true,
       'webauthn:extension:largeBlob': true,
       'webauthn:virtualAuthenticators': true
     }
ℹ Connected to ChromeDriver on port 9515 (619ms).
  Using: chrome (107.0.5304.68) on LINUX.

 Received session with ID: 6af5e2832229e552b0394eac92f88181

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

Nightwatch Configuration

const chromedriver = require("chromedriver");
const geckodriver = require("geckodriver");

require("dotenv").config();

module.exports = {
    src_folders: ["test-folder"],
    page_objects_path: ["pages"],
    custom_commands_path: "./commands",
    test_workers: false,
    start_session: true,

    // reporter output
    output_folder: './reports',
    screenshots: {
        enabled: true,
        path: './screenshots',
        on_error: true,
        on_failure: true
    },
    log_screenshot_data: true,

    test_settings: {
        default: {
            desiredCapabilities: {
                browserName: "chrome",
                "goog:chromeOptions": {
                    w3c: false,
                    args: ["--no-sandbox", "--window-size=1920,1080"]
                },
            },
            webdriver: {
                start_process: true,
                port: 9515,
                server_path: chromedriver.path
            },
        },
        firefox: {
            desiredCapabilities: {
                browserName: 'firefox'
            },
            webdriver: {
                start_process: true,
                port: 4445,
                server_path: geckodriver.path
            }
        }
    }
};

Nightwatch.js Version

3.4.1

Node Version

16

Browser

Chrome: 106.0.1

Operating System

Linux 5.15.74-1-lts

Additional Information

The independent test files work fine if called directly. But if a whole folder is called only the first one works as excpected

@LeoWie93 LeoWie93 changed the title "registerBasicAuth": does not catch when using multiple test suits "registerBasicAuth": does not apply/register when using multiple test suits Oct 27, 2022
@AutomatedTester
Copy link
Member

We need to look at how we are doing CDP sessions...

Could you add verbose logging to this issue so we can investigate further?

@LeoWie93
Copy link
Author

LeoWie93 commented Nov 1, 2022

@AutomatedTester i already gave verbose output. Although i only postetd the start of the tests.

Would you need the whole thing?

@user790235692
Copy link

Same problem here !

@gravityvi
Copy link
Member

@LeoWie93 I think logs are incomplete we would need all the logs for the whole test run which would help us rectify the issue faster.

@LeoWie93
Copy link
Author

LeoWie93 commented Nov 8, 2022

@LeoWie93 I think logs are incomplete we would need all the logs for the whole test run which would help us rectify the issue faster.

@gravityvi @AutomatedTester

here would be the whole log for two tests:
The first Test went through and the second hanged on the basic auth prompt of the browser

Logs ``` npm verb cli /home/user/.nvm/versions/node/v16.14.2/bin/node /home/user/.nvm/versions/node/v16.14.2/bin/npm npm info using npm@8.14.0 npm info using node@v16.14.2 npm timing npm:load:whichnode Completed in 0ms npm timing config:load:defaults Completed in 2ms npm timing config:load:file:/home/user/.nvm/versions/node/v16.14.2/lib/node_modules/npm/npmrc Completed in 1ms npm timing config:load:builtin Completed in 1ms npm timing config:load:cli Completed in 3ms npm timing config:load:env Completed in 0ms npm timing config:load:file:/home/user/projects/folder/folder/systeme-dir/kub-end2end-tests/.npmrc Completed in 1ms npm timing config:load:project Completed in 6ms npm timing config:load:file:/home/user/.npmrc Completed in 0ms npm timing config:load:user Completed in 0ms npm timing config:load:file:/home/user/.nvm/versions/node/v16.14.2/etc/npmrc Completed in 0ms npm timing config:load:global Completed in 0ms npm timing config:load:validate Completed in 0ms npm timing config:load:credentials Completed in 1ms npm timing config:load:setEnvs Completed in 1ms npm timing config:load Completed in 14ms npm timing npm:load:configload Completed in 14ms npm timing npm:load:mkdirpcache Completed in 0ms npm timing npm:load:mkdirplogs Completed in 0ms npm verb title npm run nightwatch ./for-github npm verb argv "run" "nightwatch" "./for-github" "--loglevel" "verbose" npm timing npm:load:setTitle Completed in 1ms npm timing config:load:flatten Completed in 2ms npm timing npm:load:display Completed in 6ms npm verb logfile logs-max:10 dir:/home/user/.npm/_logs npm verb logfile /home/user/.npm/_logs/2022-11-08T10_06_00_651Z-debug-0.log npm timing npm:load:logFile Completed in 5ms npm timing npm:load:timers Completed in 0ms npm timing npm:load:configScope Completed in 0ms npm timing npm:load Completed in 28ms

kub-tests@1.0.0 nightwatch
npx nightwatch -c nightwatch.conf.js

npm verb cli /home/user/.nvm/versions/node/v16.14.2/bin/node /home/user/.nvm/versions/node/v16.14.2/lib/node_modules/npm/bin/npm-cli.js
npm info using npm@8.14.0
npm info using node@v16.14.2
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:/home/user/.nvm/versions/node/v16.14.2/lib/node_modules/npm/npmrc Completed in 0ms
npm timing config:load:builtin Completed in 1ms
npm timing config:load:cli Completed in 1ms
npm timing config:load:env Completed in 0ms
npm timing config:load:file:/home/user/projects/folder/folder/systeme-dir/kub-end2end-tests/.npmrc Completed in 0ms
npm timing config:load:project Completed in 10ms
npm timing config:load:file:/home/user/.npmrc Completed in 0ms
npm timing config:load:user Completed in 0ms
npm timing config:load:file:/home/user/.nvm/versions/node/v16.14.2/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:validate Completed in 1ms
npm timing config:load:credentials Completed in 0ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 15ms
npm timing npm:load:configload Completed in 15ms
npm timing npm:load:mkdirpcache Completed in 1ms
npm timing npm:load:mkdirplogs Completed in 0ms
npm verb title npm exec nightwatch -c nightwatch.conf.js ./for-github
npm verb argv "exec" "--" "nightwatch" "-c" "nightwatch.conf.js" "./for-github"
npm timing npm:load:setTitle Completed in 1ms
npm timing config:load:flatten Completed in 2ms
npm timing npm:load:display Completed in 6ms
npm verb logfile logs-max:10 dir:/home/user/.npm/_logs
npm verb logfile /home/user/.npm/_logs/2022-11-08T10_06_00_968Z-debug-0.log
npm timing npm:load:logFile Completed in 5ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 31ms
(⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠴ : timing npm:load Completed in 28ms
[A10 Add private address] Test Suite
────────────────────────────────────────────────────────────────────────
ℹ Connected to ChromeDriver on port 9515 (484ms).
Using: chrome (107.0.5304.87) on LINUX.

Running step one: Login:
───────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Loaded url https://domain.com/other-path/ in 618ms
✔ Element was visible after 32 milliseconds. 28ms
✔ Testing if element <Element [name=@username]> is visible (30ms)
✔ Testing if element <Element [name=@password]> is visible (34ms)
✔ Testing if element <button[type=submit]> is visible (36ms)
✔ Testing if element <.klt-c-icon--edulog-button-large> is visible (32ms)
(⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠴ : timing npm:load Completed in 28ms
✨ PASSED. 5 assertions. (2.173s)

Running step two: Open Address Form Page:
───────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Loaded url https://domain.com/profil/adressen in 377ms
✔ Element was visible after 22 milliseconds. 28ms
✔ Testing if the page title contains 'Adressen' (7ms)
(⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠴ : timing npm:load Completed in 28ms
✨ PASSED. 2 assertions. (767ms)

Running step three: Add a Address:
───────────────────────────────────────────────────────────────────────────────────────────────────
✔ Element was visible after 32 milliseconds. 28ms
✔ Testing if the page title contains 'Adresse hinzufügen' (4ms)
(⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠴ : timing npm:load Completed in 28ms
✨ PASSED. 2 assertions. (2.555s)

Running step four: Check if the address were added:
───────────────────────────────────────────────────────────────────────────────────────────────────
✔ Element was visible after 22 milliseconds. 28ms
✔ Testing if the page title contains 'Adressen' (5ms)

✨ PASSED. 2 assertions. (29ms)

Running step five: remove added address:
───────────────────────────────────────────────────────────────────────────────────────────────────
✔ Element was visible after 17 milliseconds.
✔ Testing if element <.klt-c-icon--error> is present (14ms)
(⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠴ : timing npm:load Completed in 28ms
✨ PASSED. 2 assertions. (661ms)
(⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠴ : timing npm:load Completed in 28ms
[A11 Add school institution address] Test Suite
───────────────────────────────────────────────────────────────────────────────
ℹ Connected to ChromeDriver on port 9515 (523ms).
Using: chrome (107.0.5304.87) on LINUX.

Running step one: Login:
───────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Loaded url https://domain.com/other-path/ in 258ms
✔ Element was visible after 53 milliseconds. 28ms
✖ NightwatchAssertErrortiming npm:load Completed in 28ms
Testing if element <Element [name=@username]> is visible in 5000ms - expected "is visible" but got: "element could not be located" (5180ms)

Error location:
/home/user/projects/folder/folder/systeme-dir/kub-end2end-tests/pages/shortLogin.js:
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
 6 |         this
 7 |             .waitForElementVisible('body')
 8 |             .assert.visible('@username') 
 9 |             .setValue('@username', username)
 10 |             .assert.visible('@password')
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

(⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠴ : timing npm:load Completed in 28ms
FAILED: 1 assertions failed and 1 passed (5.752s)
(⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠴ : timing npm:load Completed in 28ms
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

️TEST FAILURE (13.157s):

  • 1 assertions failed; 14 passed
  • 5 skipped

✖ 2) for-github/a11-add_school_institution_address

– step one: Login (5.752s)

→ ✖ NightwatchAssertError
Testing if element <Element [name=@username]> is visible in 5000ms - expected "is visible" but got: "element could not be located" (5180ms)

Error location:
/home/user/projects/folder/folder/systeme-dir/kub-end2end-tests/for-github/a11-add_school_institution_address.js:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
 9 |         browser
 10 |             .url(process.env.SITE_URL + '/other-path/')
 11 |             .page.shortLogin().loginWithEnvUser(); 
 12 |     });
 13 | 
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

SKIPPED:
- step two: Open Address Form Page
- step three: Add a Address
- step four: Check if the address were added
- step five: Check if the address were added
- step six: remove added address

Wrote HTML report file to: /home/user/projects/folder/folder/systeme-dir/kub-end2end-tests/reports/nightwatch-html-report/index.html

npm timing command:exec Completed in 13510ms
npm verb exit 5
npm timing npm Completed in 13625ms
npm verb code 5
npm timing command:run Completed in 13916ms
npm verb exit 5
npm timing npm Completed in 13952ms

</details>

@fokayx
Copy link

fokayx commented Jan 4, 2023

@gravityvi @AutomatedTester
Our team solved registerBasicAuth in multiple test suits error if we set CDP connection reset = true. Can Nightwatch add reset CDP here to make registerBasicAuth work?

@LeoWie93
Copy link
Author

LeoWie93 commented Jan 30, 2023

@gravityvi @AutomatedTester Our team solved registerBasicAuth in multiple test suits error if we set CDP connection reset = true. Can Nightwatch add reset CDP here to make registerBasicAuth work?

@AutomatedTester Are their any news on this and the issue in general?

@gravityvi
Copy link
Member

Hey @LeoWie93 I will look into this issue and raise a PR to fix this.

@gravityvi gravityvi self-assigned this Feb 1, 2023
@gravityvi gravityvi changed the title "registerBasicAuth": does not apply/register when using multiple test suits CDP commands does not reset the connection after a test session ends Feb 1, 2023
@gravityvi gravityvi changed the title CDP commands does not reset the connection after a test session ends CDP does not reset the connection after a test session ends Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants