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

browser.window.open('tab') error in incognito "Failed to open new tab - no browser is open" #4222

Open
reallymello opened this issue Jun 13, 2024 · 1 comment

Comments

@reallymello
Copy link
Contributor

reallymello commented Jun 13, 2024

Description of the bug/issue

When I run my test suite using

chromeOptions: {
          args: ['--incognito'],
        },

and I open a new tab in my test using browser.window.open('tab') I expect a new tab to open, but instead I receive error

Error   Error while running .openNewWindow() protocol action: unknown error: unhandled inspector error: {"code":-32000,"message":"Failed to open new tab - no browser is open"}   │
│     (Session info: chrome=126.0.6478.61)     

image

Steps to reproduce

Run npx nightwatch with your nightwatch.conf.js using the chrome incognito args

Sample test

import { NightwatchTests } from 'nightwatch';

const home: NightwatchTests = {
  'New tab test': () => {
    browser.url('https://google.com/ncr').assert.titleEquals('Google');

    browser.window.open('tab');
  },
  after: () => {
    browser.end();
  },
};

export default home;

Command to run

npx nightwatch

Verbose Output

npx nightwatch --verbose
 Launching up to 1 concurrent test worker processes...

Running   default: google.ts  

DevTools listening on ws://127.0.0.1:56419/devtools/browser/f38c44f4-86da-4ad3-8462-a04d8fa448b5
┌ ────────────────── √  default: google.ts  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                                                                                              │
│   default [Nightwatch\google] Test Suite                                                                                                                                                     │
│   default ────────────────────────────────────────────────────────────                                                                                                                       │
│   default Starting ChromeDriver...                                                                                                                                                           │
│   default (node:28968) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.                                                         │
│   default (Use `node --trace-deprecation ...` to show where the warning was created)                                                                                                         │
│   default   Request POST /session                                                                                                                                                            │
│   default {                                                                                                                                                                                  │
│   default      capabilities: {                                                                                                                                                               │
│   default        firstMatch: [ {} ],                                                                                                                                                         │
│   default        alwaysMatch: {                                                                                                                                                              │
│   default          browserName: 'chrome',                                                                                                                                                    │
│   default          'goog:chromeOptions': {                                                                                                                                                   │
│   default            args: [ '--incognito' ],                                                                                                                                                │
│   default            binary: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'                                                                                                    │
│   default          }                                                                                                                                                                         │
│   default        }                                                                                                                                                                           │
│   default      }                                                                                                                                                                             │
│   default   }                                                                                                                                                                                │
│   default   Response 200 POST /session (461ms)                                                                                                                                               │
│   default {                                                                                                                                                                                  │
│   default      value: {                                                                                                                                                                      │
│   default        capabilities: {                                                                                                                                                             │
│   default          acceptInsecureCerts: false,                                                                                                                                               │
│   default          browserName: 'chrome',                                                                                                                                                    │
│   default          browserVersion: '126.0.6478.61',                                                                                                                                          │
│   default          chrome: {                                                                                                                                                                 │
│   default            chromedriverVersion: '126.0.6478.61 (8dc092df54ce9b93406cb7fec530eb297bc0b332-refs/branch-heads/6478_56@{#3})',                                                         │
│   default            userDataDir: 'C:\\Users\\agent\\AppData\\Local\\Temp\\scoped_dir6032_680883214'                                                                                         │
│   default          },                                                                                                                                                                        │
│   default          'fedcm:accounts': true,                                                                                                                                                   │
│   default          'goog:chromeOptions': { debuggerAddress: 'localhost:56419' },                                                                                                             │
│   default          networkConnectionEnabled: false,                                                                                                                                          │
│   default          pageLoadStrategy: 'normal',                                                                                                                                               │
│   default          platformName: 'windows',                                                                                                                                                  │
│   default          proxy: {},                                                                                                                                                                │
│   default          setWindowRect: true,                                                                                                                                                      │
│   default          strictFileInteractability: false,                                                                                                                                         │
│   default          timeouts: { implicit: 0, pageLoad: 300000, script: 30000 },                                                                                                               │
│   default          unhandledPromptBehavior: 'dismiss and notify',                                                                                                                            │
│   default          'webauthn:extension:credBlob': true,                                                                                                                                      │
│   default          'webauthn:extension:largeBlob': true,                                                                                                                                     │
│   default          'webauthn:extension:minPinLength': true,                                                                                                                                  │
│   default          'webauthn:extension:prf': true,                                                                                                                                           │
│   default          'webauthn:virtualAuthenticators': true                                                                                                                                    │
│   default        },                                                                                                                                                                          │
│   default        sessionId: 'b93b691d526b8a71df120a848a4a929a'                                                                                                                               │
│   default      }                                                                                                                                                                             │
│   default   }                                                                                                                                                                                │
│   default Using: chrome (126.0.6478.61) on WINDOWS.                                                                                                                                          │
│   default Received session with ID: b93b691d526b8a71df120a848a4a929a                                                                                                                         │
│   default                                                                                                                                                                                    │
│   default → Running [before]:                                                                                                                                                                │
│   default → Completed [before].                                                                                                                                                              │
│   default – New tab test                                                                                                                                                                     │
│   default → Running [beforeEach]:                                                                                                                                                            │
│   default → Completed [beforeEach].                                                                                                                                                          │
│   default → Running command: url ('https://google.com/ncr')                                                                                                                                  │
│   default - Loading url: https://google.com/ncr                                                                                                                                              │
│   default   Request POST /session/b93b691d526b8a71df120a848a4a929a/url                                                                                                                       │
│   default { url: 'https://google.com/ncr' }                                                                                                                                                  │
│   default   Response 200 POST /session/b93b691d526b8a71df120a848a4a929a/url (798ms)                                                                                                          │
│   default { value: null }                                                                                                                                                                    │
│   default ℹ Loaded url https://google.com/ncr in 800ms                                                                                                                                       │
│   default → Completed command: url ('https://google.com/ncr') (800ms)                                                                                                                        │
│   default → Running command: assert.titleEquals ('Google')                                                                                                                                   │
│   default → Running command: title ([Function])                                                                                                                                              │
│   default   Request GET /session/b93b691d526b8a71df120a848a4a929a/title                                                                                                                      │
│   default   Response 200 GET /session/b93b691d526b8a71df120a848a4a929a/title (3ms)                                                                                                           │
│   default { value: 'Google' }                                                                                                                                                                │
│   default √ Testing if the page title equals 'Google' (15ms)                                                                                                                                 │
│   default → Completed command: title ([Function]) (4ms)                                                                                                                                      │
│   default → Completed command: assert.titleEquals ('Google') (28ms)                                                                                                                          │
│   default → Running command: window.open ('tab')                                                                                                                                             │
│   default   Request POST /session/b93b691d526b8a71df120a848a4a929a/window/new                                                                                                                │
│   default { type: 'tab' }                                                                                                                                                                    │
│   default Error                                                                                                                                                                              │
│   default      Response 500 POST /session/b93b691d526b8a71df120a848a4a929a/window/new (2ms)                                                                                                  │
│   default {                                                                                                                                                                                  │
│   default      value: {                                                                                                                                                                      │
│   default        error: 'unknown error',                                                                                                                                                     │
│   default        message: 'unknown error: unhandled inspector error: {"code":-32000,"message":"Failed to open new tab - no browser is open"}\n' +                                            │
│   default          '  (Session info: chrome=126.0.6478.61)',                                                                                                                                 │
│   default        stacktrace: ''                                                                                                                                                              │
│   default      }                                                                                                                                                                             │
│   default   }                                                                                                                                                                                │
│   default   Request POST /session/b93b691d526b8a71df120a848a4a929a/window/new  (retry 1)                                                                                                     │
│   default { type: 'tab' }                                                                                                                                                                    │
│   default Error                                                                                                                                                                              │
│   default      Response 500 POST /session/b93b691d526b8a71df120a848a4a929a/window/new (3ms)                                                                                                  │
│   default {                                                                                                                                                                                  │
│   default      value: {                                                                                                                                                                      │
│   default        error: 'unknown error',                                                                                                                                                     │
│   default        message: 'unknown error: unhandled inspector error: {"code":-32000,"message":"Failed to open new tab - no browser is open"}\n' +                                            │
│   default          '  (Session info: chrome=126.0.6478.61)',                                                                                                                                 │
│   default        stacktrace: ''                                                                                                                                                              │
│   default      }                                                                                                                                                                             │
│   default   }                                                                                                                                                                                │
│   default   Request POST /session/b93b691d526b8a71df120a848a4a929a/window/new  (retry 2)                                                                                                     │
│   default { type: 'tab' }                                                                                                                                                                    │
│   default Error                                                                                                                                                                              │
│   default      Response 500 POST /session/b93b691d526b8a71df120a848a4a929a/window/new (8ms)                                                                                                  │
│   default {                                                                                                                                                                                  │
│   default      value: {                                                                                                                                                                      │
│   default        error: 'unknown error',                                                                                                                                                     │
│   default        message: 'unknown error: unhandled inspector error: {"code":-32000,"message":"Failed to open new tab - no browser is open"}\n' +                                            │
│   default          '  (Session info: chrome=126.0.6478.61)',                                                                                                                                 │
│   default        stacktrace: ''                                                                                                                                                              │
│   default      }                                                                                                                                                                             │
│   default   }                                                                                                                                                                                │
│   default Error   Error while running .openNewWindow() protocol action: unknown error: unhandled inspector error: {"code":-32000,"message":"Failed to open new tab - no browser is open"}    │
│   default   (Session info: chrome=126.0.6478.61)                                                                                                                                             │
│   default                                                                                                                                                                                    │
│   default → Completed command: window.open ('tab') (2045ms)                                                                                                                                  │
│   default → Running [afterEach]:                                                                                                                                                             │
│   default → Completed [afterEach].                                                                                                                                                           │
│   default √ default [Nightwatch\google] New tab test (2.881s)                                                                                                                                │
│   default → Running [after]:                                                                                                                                                                 │
│   default → Running command: end ()                                                                                                                                                          │
│   default → Running command: session ('delete', [Function])                                                                                                                                  │
│   default   Request DELETE /session/b93b691d526b8a71df120a848a4a929a                                                                                                                         │
│   default   Response 200 DELETE /session/b93b691d526b8a71df120a848a4a929a (51ms)                                                                                                             │
│   default { value: null }                                                                                                                                                                    │
│   default → Completed command: end () (69ms)                                                                                                                                                 │
│   default → Completed command: session ('delete', [Function]) (53ms)                                                                                                                         │
│   default → Completed [after].                                                                                                                                                               │
│                                                                                                                                                                                              │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
 Wrote HTML report file to: C:\Users\agent\Desktop\unhandledBug\tests_output\nightwatch-html-report\index.html

 Wrote Rerun Json report file to: C:\Users\agent\Desktop\unhandledBug\tests_output\minimal_report.json
 Wrote JSON report file to: C:\Users\agent\Desktop\unhandledBug\tests_output\nightwatch\CHROME_126.0.6478.61__google.json
 Wrote XML report file to: C:\Users\agent\Desktop\unhandledBug\tests_output\nightwatch\CHROME_126.0.6478.61__google.xml
 Analytics send event:
   {
     client_id: 'c070c219-2910-4cc5-ae77-09dd2e262df0',
     non_personalized_ads: true,
     timestamp_micros: 1718319663066000,
     events: [
       {
         name: 'nw_test_run',
         params: {
           arg_parallel: 'undefined',
           browser_name: 'chrome',
           test_workers_enabled: true,
           use_xpath: false,
           is_bstack: false,
           test_runner: 'default',
           event_time: 1718319658741000,
           env_os: 'win32/10.0.22631/Intel(R) Core(TM) i7-14700KF',
           env_lang: 'en_US.UTF-8',
           env_nw_version: '3.6.3',
           env_node_version: 'node v21.6.2',
           test_env: 'default',
           run_id: 'e06269e6-7d44-4ddf-b38c-c6a0b3a7ad94'
         }
       },
       {
         name: 'nw_test_run',
         params: {
           arg_parallel: 'undefined',
           browser_name: 'chrome',
           test_workers_enabled: true,
           use_xpath: false,
           is_bstack: false,
           test_runner: 'default',
           event_time: 1718319659050000,
           env_os: 'win32/10.0.22631/Intel(R) Core(TM) i7-14700KF',
           env_lang: 'en_US.UTF-8',
           env_nw_version: '3.6.3',
           env_node_version: 'node v21.6.2',
           test_env: 'default',
           run_id: '0b1d131f-6d80-488c-9e42-5d0e5c23990b'
         }
       }
     ]
  }

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: ['test', 'nightwatch'],

  // See https://nightwatchjs.org/guide/concepts/page-object-model.html
  page_objects_path: [],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
  custom_commands_path: [],

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

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

  // See https://nightwatchjs.org/guide/concepts/test-globals.html
  globals_path: '',

  webdriver: {},

  test_workers: {
    enabled: true,
  },

  test_settings: {
    default: {
      disable_error_log: false,
      launch_url: 'http://localhost',

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

      desiredCapabilities: {
        browserName: 'chrome',
        chromeOptions: {
          args: ['--incognito'],
        },
      },

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

    chrome: {
      desiredCapabilities: {
        browserName: 'chrome',
        'goog:chromeOptions': {
          // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
          args: [
            //'--no-sandbox',
            //'--ignore-certificate-errors',
            //'--allow-insecure-localhost',
            //'--headless=new'
          ],
        },
      },

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

  usage_analytics: {
    enabled: true,
    log_path: './logs/analytics',
    client_id: 'c070c219-2910-4cc5-ae77-09dd2e262df0',
  },
};

Nightwatch.js Version

3.6.3

Node Version

21.6.2

Browser

Chrome 126.0.6478.61

Operating System

Windows 11

Additional Information

browser.window.open('window'); appears to work fine, browser.window.open('tab'); does not and it only seems to occur under incognito mode operation

@garg3133
Copy link
Member

This seems to be a chromedriver issue, so it might help to raise it directly on their issue tracker with minimal reproducible steps.

Also, I'd suggest sharing a Selenium example snippet with them for opening a new tab instead of a Nightwatch one: https://www.selenium.dev/documentation/webdriver/interactions/windows/#create-new-window-or-new-tab-and-switch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants