DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.82k stars 670 forks source link

Unhandled promise Rejection: Error: Invalid InterceptionId #7743

Closed port-eighty closed 1 year ago

port-eighty commented 1 year ago

What is your Scenario?

After installing testcafe@latest (2.6.1) I started getting the error described by the title in my tests, I've reproduced it in a simple test file:

What is the Current behavior?

Getting unhandled promise rejection error

What is the Expected behavior?

Test should complete normally

What is your public website URL? (or attach your complete example)

www.google.com

What is your TestCafe test code?

import { Selector } from 'testcafe'
const searchBar = Selector('textarea')
const wikipediaSelector = Selector('h3').withText('Wikipedia')
const wikiPage = Selector('#siteSub')
fixture(`Testing proxyless`)
  .page('www.google.com')
  .beforeEach(async t => {})
test(`Test A`, async t => {
  await t.navigateTo('https://www.google.com/webhp')
  await t.typeText(searchBar, 'a').pressKey('enter')
  await t.click(wikipediaSelector)
  await t
    .expect(wikiPage.textContent)
    .eql('From Wikipedia, the free encyclopedia')
})
test(`Test B`, async t => {
  await t.navigateTo('https://www.google.com/webhp')
  await t.typeText(searchBar, 'a').pressKey('enter')
  await t.click(wikipediaSelector)
  await t
    .expect(wikiPage.textContent)
    .eql('From Wikipedia, the free encyclopedia')
})
test(`Test C`, async t => {
  await t.navigateTo('https://www.google.com/webhp')
  await t.typeText(searchBar, 'a').pressKey('enter')
  await t.click(wikipediaSelector)
  await t
    .expect(wikiPage.textContent)
    .eql('From Wikipedia, the free encyclopedia')
})

Your complete configuration file

const apiLogger = require(`./Logger`)
module.exports = {
  hooks: {
    request: apiLogger,
  },
  nativeAutomation: true,
  skipJsErrors: true,
  pageLoadTimeout: 60000,
  reporter: 'list',
}

Your complete test report


× Testing proxyless - Test A

1) Unhandled promise rejection:

   Error: Invalid InterceptionId.
   at C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:94:35
   at Chrome._handleMessage (C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:261:17)
   at WebSocket.<anonymous> (C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:239:22)
   at WebSocket.emit (node:events:527:28)
   at WebSocket.emit (node:domain:475:12)
   at Receiver.receiverOnMessage (C:\Users\<REDACTED>\node_modules\ws\lib\websocket.js:1068:20)
   at Receiver.emit (node:events:527:28)
   at Receiver.emit (node:domain:475:12)
   at Receiver.dataMessage (C:\Users\<REDACTED>\node_modules\ws\lib\receiver.js:517:14)
   at Receiver.getData (C:\Users\<REDACTED>\node_modules\ws\lib\receiver.js:435:17)

   Browser: Chrome 113.0.0.0 / Windows 10

× Testing proxyless - Test B

1) Unhandled promise rejection:

   Error: Invalid InterceptionId.
   at C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:94:35
   at Chrome._handleMessage (C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:261:17)
   at WebSocket.<anonymous> (C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:239:22)
   at WebSocket.emit (node:events:527:28)
   at WebSocket.emit (node:domain:475:12)
   at Receiver.receiverOnMessage (C:\Users\<REDACTED>\node_modules\ws\lib\websocket.js:1068:20)
   at Receiver.emit (node:events:527:28)
   at Receiver.emit (node:domain:475:12)
   at Receiver.dataMessage (C:\Users\<REDACTED>\node_modules\ws\lib\receiver.js:517:14)
   at Receiver.getData (C:\Users\<REDACTED>\node_modules\ws\lib\receiver.js:435:17)

   Browser: Chrome 113.0.0.0 / Windows 10

× Testing proxyless - Test C

1) Unhandled promise rejection:

   Error: Invalid InterceptionId.
   at C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:94:35
   at Chrome._handleMessage (C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:261:17)
   at WebSocket.<anonymous> (C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:239:22)
   at WebSocket.emit (node:events:527:28)
   at WebSocket.emit (node:domain:475:12)
   at Receiver.receiverOnMessage (C:\Users\<REDACTED>\node_modules\ws\lib\websocket.js:1068:20)
   at Receiver.emit (node:events:527:28)
   at Receiver.emit (node:domain:475:12)
   at Receiver.dataMessage (C:\Users\<REDACTED>\node_modules\ws\lib\receiver.js:517:14)
   at Receiver.getData (C:\Users\<REDACTED>\node_modules\ws\lib\receiver.js:435:17)

   Browser: Chrome 113.0.0.0 / Windows 10

Screenshots

No response

Steps to Reproduce

  1. Run the example script described above
  2. Observe the console for errors

TestCafe version

2.6.1

Node.js version

16.15.0 and 19.8.1

Command-line arguments

testcafe chrome ./experiments2.js

Browser name(s) and version(s)

Chrome 113.0.0.0 / Windows 10

Platform(s) and version(s)

Windows 10

Other

Was trying to debug and replicate this error from another issue:

- Error in fixture.beforeEach hook -
      Unhandled promise rejection:
      Error: Inspected target navigated or closed
      at C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:94:35
      at Chrome._handleMessage (C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:261:17)
      at WebSocket.<anonymous> (C:\Users\<REDACTED>\node_modules\chrome-remote-interface\lib\chrome.js:239:22)
      at WebSocket.emit (node:events:527:28)
      at WebSocket.emit (node:domain:475:12)
      at Receiver.receiverOnMessage (C:\Users\<REDACTED>\node_modules\ws\lib\websocket.js:1068:20)
      at Receiver.emit (node:events:527:28)
      at Receiver.emit (node:domain:475:12)
      at Receiver.dataMessage (C:\Users\<REDACTED>\node_modules\ws\lib\receiver.js:517:14)
      at Receiver.getData (C:\Users\<REDACTED>\node_modules\ws\lib\receiver.js:435:17)

      Browser: Chrome 113.0.5672.127 / Windows 10
miherlosev commented 1 year ago

Hi @port-eighty,

I cannot run the shared example because you didn't attach all necessary files. Could you please share all files from the ./Logger folder?

port-eighty commented 1 year ago

@miherlosev I don't have a ./Logger folder.

If by chance you're asking what the contents of Logger.js is, then here it is:


const { RequestLogger } = require('testcafe')

module.exports = new RequestLogger(/api/, {
  logRequestHeaders: true,
  logRequestBody: true,
  logResponseHeaders: true,
  logResponseBody: true,
  stringifyResponseBody: true,
})

This implementation is directly from : TestCafe Documentation - Define global hooks

miherlosev commented 1 year ago

Hi @port-eighty

Thank you for sharing the detailed information. I've reproduced the issue.

github-actions[bot] commented 1 year ago

Release v3.0.0-rc.1 addresses this.