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

Error "Error with Permissions-Policy header" when using --headless on example tests #3589

Closed
reallymello opened this issue Jan 29, 2023 · 4 comments

Comments

@reallymello
Copy link
Contributor

reallymello commented Jan 29, 2023

Description of the bug/issue

When I run the example duckDuckGo.ts and ecosia.ts scripts that come with the npm init nightwatch scaffolder using --headless I expect the test to execute without console info errors, but instead I receive

[0129/121246.799:INFO:CONSOLE(0)] "Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'interest-cohort'.", source:  (0)
[0129/121247.779:INFO:CONSOLE(3)] "Request for the Private Access Token challenge.", source:  (3)
[0129/121247.779:INFO:CONSOLE(3)] "The next request for the Private Access Token challenge may return a 401 and show a warning in console.", source:  (3)
[0129/121247.814:INFO:CONSOLE(3)] "console.groupEnd", source:  (3)
[0129/121250.215:INFO:CONSOLE(0)] "Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'interest-cohort'.", source:  (0)
[0129/121250.990:INFO:CONSOLE(3)] "Request for the Private Access Token challenge.", source:  (3)
[0129/121250.990:INFO:CONSOLE(3)] "The next request for the Private Access Token challenge may return a 401 and show a warning in console.", source:  (3)
[0129/121251.039:INFO:CONSOLE(3)] "console.groupEnd", source:  (3)

The error is logged only when run as headless.

Steps to reproduce

  1. Run npm init nightwatch@latest
  2. Select, typescript and end-to-end for your configuration with chrome as your browser
  3. After setup, execute npx nightwatch .\nightwatch\ecosia.ts --headless or npx nightwatch .\nightwatch\duckDuckGo.ts --headless

Sample test

Use included ecosia.ts or duckDuckGo.ts scripts that come with npm init nightwatch

Command to run

npx nightwatch .\nightwatch\ecosia.ts --headless
npx nightwatch .\nightwatch\duckDuckGo.ts --headless

Verbose Output

PS C:\Users\Mr\Desktop\apiTests> npx nightwatch .\nightwatch\ecosia.ts --headless --verbose 
 Now you can run TS tests directly using Nightwatch.


[Ecosia.org Demo] Test Suite
────────────────────────────────────────────────────────
⠋ Starting ChromeDriver on port 9515...
 Starting ChromeDriver with server_path=C:\Users\Mr\Desktop\apiTests\node_modules\chromedriver\lib\chromedriver\chromedriver.exe...
   Request POST /session  
   {
     capabilities: {
       firstMatch: [ {} ],
       alwaysMatch: {
         browserName: 'chrome',
         'goog:chromeOptions': { args: [ 'headless=chrome' ] }
       }
     }
⠙ Starting ChromeDriver on port 9515...

⠴ Starting ChromeDriver on port 9515...
   Response 200 POST /session (462ms)
   {
     value: {
       capabilities: {
         acceptInsecureCerts: false,
         browserName: 'chrome',
         browserVersion: '109.0.5414.120',
         chrome: {
           chromedriverVersion: '109.0.5414.74 (e7c5703604daa9cc128ccf5a5d3e993513758913-refs/branch-heads/5414@{#1172})',
           userDataDir: 'C:\\Users\\Mr\\AppData\\Local\\Temp\\scoped_dir26376_1613780555'
         },
         'goog:chromeOptions': { debuggerAddress: 'localhost:57094' },
         networkConnectionEnabled: false,
         pageLoadStrategy: 'normal',
         platformName: 'windows',
         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: '3dbf8e93eaec4f604e41ccc94168bf50'
     }
ℹ Connected to ChromeDriver on port 9515 (528ms).
  Using: chrome (109.0.5414.120) on WINDOWS.

 Received session with ID: 3dbf8e93eaec4f604e41ccc94168bf50

 → Running [before]:
 
 → Running command: navigateTo ('https://www.ecosia.org/')     
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/url  
   { url: 'https://www.ecosia.org/' }
[0129/121636.331:INFO:CONSOLE(18)] "
oooooooooooo                               o8o
`888'     `8                               `"'
 888          .ooooo.   .ooooo.   .oooo.o oooo   .oooo.
 888oooo8    d88' `"Y8 d88' `88b d88(  "8 `888  `P  )88b
 888    "    888       888   888 `"Y88b.   888   .oP"888
 888       o 888   .o8 888   888 o.  )88b  888  d8(  888
o888ooooood8 `Y8bod8P' `Y8bod8P' 8""888P' o888o `Y888""8o

We love JavaScript too - why not code and plant trees? Check out https://explore.ecosia.org/jobs

", source: https://cdn-indexpage.ecosia.org/7b5f366.js (18)
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/url (730ms)
   { value: null }
  → Completed command: navigateTo ('https://www.ecosia.org/') (734ms)
 → Completed [before].



  Running Demo test ecosia.org:
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 → Running [beforeEach]:
 → Completed [beforeEach].
 
 → Running command: waitForElementVisible ('body')
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: 'body' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (13ms)
   {
     value: [
       {
         'element-6066-11e4-a52e-4f735466cecf': '517809a5-1cb5-47c6-8042-bb791025686a'
       }
     ]
  }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/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': '517809a5-1cb5-47c6-8042-bb791025686a',
         ELEMENT: '517809a5-1cb5-47c6-8042-bb791025686a'
       }
     ]
  }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/execute/sync (15ms)
   { value: true }
  √ Element <body> was visible after 34 milliseconds.
  → Completed command: waitForElementVisible ('body') (38ms)

 → Running command: assert.titleContains ('Ecosia')
 
 → Running command: title ([Function])
   Request GET /session/3dbf8e93eaec4f604e41ccc94168bf50/title  

   Response 200 GET /session/3dbf8e93eaec4f604e41ccc94168bf50/title (12ms)
   { value: 'Ecosia - the search engine that plants trees' }
  √ Testing if the page title contains 'Ecosia' (31ms)
  → Completed command: title ([Function]) (15ms)
  → Completed command: assert.titleContains ('Ecosia') (36ms)

 → Running command: assert.visible ('input[type=search]')
 
 → Running command: isVisible ({selector, suppressNotFoundErrors}, [Function])
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: 'input[type=search]' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (9ms)
   {
     value: [
       {
         'element-6066-11e4-a52e-4f735466cecf': '9867b633-d4c7-4fa1-9a79-9aa122ee2144'
       }
     ]
  }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/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': '9867b633-d4c7-4fa1-9a79-9aa122ee2144',
         ELEMENT: '9867b633-d4c7-4fa1-9a79-9aa122ee2144'
       }
     ]
  }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/execute/sync (14ms)
   { value: true }
  √ Testing if element <input[type=search]> is visible (42ms)
  → Completed command: isVisible ({selector, suppressNotFoundErrors}, [Function]) (28ms)
  → Completed command: assert.visible ('input[type=search]') (45ms)

 → Running command: setValue ('input[type=search]', 'nightwatch')
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: 'input[type=search]' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (6ms)
   {
     value: [
       {
         'element-6066-11e4-a52e-4f735466cecf': '9867b633-d4c7-4fa1-9a79-9aa122ee2144'
       }
     ]
  }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/element/9867b633-d4c7-4fa1-9a79-9aa122ee2144/clear  
{}
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/element/9867b633-d4c7-4fa1-9a79-9aa122ee2144/clear (25ms)
   { value: null }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/element/9867b633-d4c7-4fa1-9a79-9aa122ee2144/value  
   {
     text: 'nightwatch',
     value: [
       'n', 'i', 'g', 'h',
       't', 'w', 'a', 't',
       'c', 'h'
     ]
  }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/element/9867b633-d4c7-4fa1-9a79-9aa122ee2144/value (47ms)
   { value: null }
  → Completed command: setValue ('input[type=search]', 'nightwatch') (84ms)

 → Running command: assert.visible ('button[type=submit]')
 
 → Running command: isVisible ({selector, suppressNotFoundErrors}, [Function])
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: 'button[type=submit]' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (9ms)
   {
     value: [
       {
         'element-6066-11e4-a52e-4f735466cecf': '96d8a430-3111-4ecf-8c8f-dbcf57af0114'
       }
     ]
  }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/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': '96d8a430-3111-4ecf-8c8f-dbcf57af0114',
         ELEMENT: '96d8a430-3111-4ecf-8c8f-dbcf57af0114'
       }
     ]
  }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/execute/sync (11ms)
   { value: true }
  √ Testing if element <button[type=submit]> is visible (33ms)
  → Completed command: isVisible ({selector, suppressNotFoundErrors}, [Function]) (23ms)
  → Completed command: assert.visible ('button[type=submit]') (35ms)

 → Running command: click ('button[type=submit]')
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: 'button[type=submit]' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (6ms)
   {
     value: [
       {
         'element-6066-11e4-a52e-4f735466cecf': '96d8a430-3111-4ecf-8c8f-dbcf57af0114'
       }
     ]
  }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/element/96d8a430-3111-4ecf-8c8f-dbcf57af0114/click  
{}
[0129/121636.840:INFO:CONSOLE(0)] "Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'interest-cohort'.", source:  (0)
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/element/96d8a430-3111-4ecf-8c8f-dbcf57af0114/click (151ms)
   { value: null }
  → Completed command: click ('button[type=submit]') (161ms)

 → Running command: assert.textContains ('.layout__content', 'Nightwatch.js')
 
 → Running command: getText ({selector, suppressNotFoundErrors}, [Function])
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: '.layout__content' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (9ms)
   { value: [] }
[0129/121637.108:INFO:CONSOLE(3)] "Request for the Private Access Token challenge.", source:  (3)
[0129/121637.109:INFO:CONSOLE(3)] "The next request for the Private Access Token challenge may return a 401 and show a warning in console.", source:  (3)
[0129/121637.138:INFO:CONSOLE(3)] "console.groupEnd", source:  (3)
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: '.layout__content' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (95ms)
   { value: [] }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: '.layout__content' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (6ms)
   { value: [] }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: '.layout__content' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (6ms)
   { value: [] }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: '.layout__content' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (6ms)
   { value: [] }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: '.layout__content' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (6ms)
   { value: [] }
[0129/121640.024:INFO:CONSOLE(0)] "Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'interest-cohort'.", source:  (0)
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: '.layout__content' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (6ms)
   { value: [] }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: '.layout__content' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (227ms)
   { value: [] }
[0129/121641.084:INFO:CONSOLE(3)] "Request for the Private Access Token challenge.", source:  (3)
[0129/121641.084:INFO:CONSOLE(3)] "The next request for the Private Access Token challenge may return a 401 and show a warning in console.", source:  (3)
[0129/121641.109:INFO:CONSOLE(3)] "console.groupEnd", source:  (3)
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: '.layout__content' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (6ms)
   { value: [] }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: '.layout__content' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (6ms)
   { value: [] }
   Request POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements  
   { using: 'css selector', value: '.layout__content' }
   Response 200 POST /session/3dbf8e93eaec4f604e41ccc94168bf50/elements (7ms)
   { value: [] }
  ✖ NightwatchAssertError
   Testing if element <.layout__content> contains text 'Nightwatch.js' in 5000ms - expected "contains text 'Nightwatch.js'" but got: "element could not be located" (5486ms)

    Error location:
    C:\Users\Mr\Desktop\apiTests\nightwatch\ecosia.ts:
    –––––––––––––––––––––––––––––––––––––––––––––––––––
     12 |       .assert.visible('button[type=submit]')
     13 |       .click('button[type=submit]')
     14 |       .assert.textContains('.layout__content', 'Nightwatch.js'); 
     15 |   });
     16 |
    –––––––––––––––––––––––––––––––––––––––––––––––––––

  → Completed command: getText ({selector, suppressNotFoundErrors}, [Function]) (5477ms)
  → Completed command: assert.textContains ('.layout__content', 'Nightwatch.js') (5493ms)
 → Running [afterEach]:
 → Completed [afterEach].

  FAILED: 1 assertions failed and  4 passed (5.972s)
 → Running [after]:
 
 → Running command: end ()
 
 → Running command: session ('delete', [Function])
   Request DELETE /session/3dbf8e93eaec4f604e41ccc94168bf50  

   Response 200 DELETE /session/3dbf8e93eaec4f604e41ccc94168bf50 (14ms)
   { value: null }
  → Completed command: end () (33ms)
  → Completed command: session ('delete', [Function]) (18ms)
 → Completed [after].

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  ️TEST FAILURE (9.519s):
   - 1 assertions failed; 4 passed

   × 1) nightwatch\ecosia

   – Demo test ecosia.org (5.972s)

   → ✖ NightwatchAssertError
   Testing if element <.layout__content> contains text 'Nightwatch.js' in 5000ms - expected "contains text 'Nightwatch.js'" but got: "element could not be located" (5486ms)

    Error location:
    C:\Users\Mr\Desktop\apiTests\nightwatch\ecosia.ts:
    –––––––––––––––––––––––––––––––––––––––––––––––––––
     12 |       .assert.visible('button[type=submit]')
     13 |       .click('button[type=submit]')
     14 |       .assert.textContains('.layout__content', 'Nightwatch.js'); 
     15 |   });
     16 |
    –––––––––––––––––––––––––––––––––––––––––––––––––––


 Wrote HTML report file to: C:\Users\Mr\Desktop\apiTests\tests_output\nightwatch-html-report\index.html

 Wrote JSON report file to: C:\Users\Mr\Desktop\apiTests\tests_output\nightwatch\CHROME_109.0.5414.120__ecosia.json
 Wrote XML report file to: C:\Users\Mr\Desktop\apiTests\tests_output\nightwatch\CHROME_109.0.5414.120__ecosia.xml

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: ['tests','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'
      },
      
      webdriver: {
        start_process: true,
        server_path: ''
      },
      
    },
    
    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
        ]
      }
    },
    
  },
  
};

Nightwatch.js Version

2.6.10

Node Version

16.15.0

Browser

Chrome 109.0.5414.120

Operating System

Windows 10

Additional Information

No response

@beatfactor
Copy link
Member

There's a new PR related to Chrome headless. Can you check if #3581 fixes it?

@reallymello
Copy link
Contributor Author

Yes @beatfactor that fixes it with the new options.js in that PR. Should we leave this issue open until that is published?

@beatfactor
Copy link
Member

yeah, we'll publish a 2.6.11 patch version soon.

@beatfactor
Copy link
Member

should be fixed now.

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

3 participants