Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Puppeteer fails subsequent tests if beforeunload popup shown

Aperta
#3,068 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
testing

Direzione di ricerca

Riproducete lo scenario restart:false a partire dagli snippet HTML e JavaScript forniti, quindi esaminate lib/helper/Puppeteer.js in corrispondenza della gestione del dialog segnalata alla riga 483 e lib/listener/steps.js in corrispondenza della riga 55. Verificate che un popup beforeunload non interrompa il test successivo e non causi errori di completamento duplicati, quindi confermate che l’esecuzione riporti lo stato di errore corretto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What are you trying to achieve?

When testing a page which shows a popup on unload (beforeunload event), CodeceptJS fails if restart: false is set.

The issue is not present when restart: true is set.

Additionally, process exits with code 0, indicating a success.

I couldn't successfully accept the popup, and I tried at the end of the first test, at the beginning on the second test, and in _before handler.

Example project: https://github.com/dejanceltra/codeceptjs-popup-issue
CodeceptJS run: https://github.com/dejanceltra/codeceptjs-popup-issue/runs/3836071868

What do you get instead?
npx codeceptjs run
  shell: /usr/bin/bash -e {0}
creating output directory: /home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/output
CodeceptJS v3.1.3
Using test root "/home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue"

test --

  ✔ test something in 133ms
Popup already exists and was not closed. Popups must always be closed by calling either I.acceptPopup() or I.cancelPopup()

  ✖ test something 2 in 109ms
Error processing test.passed event:
TypeError: Cannot convert undefined or null to object
    at EventEmitter.<anonymous> (/home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/node_modules/codeceptjs/lib/listener/steps.js:55:5)
    at EventEmitter.emit (node:events:402:35)
    at Object.emit (/home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/node_modules/codeceptjs/lib/event.js:145:28)
    at /home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/node_modules/codeceptjs/lib/scenario.js:96:15

  ✖ test something 2 in 109ms

-- FAILURES:

  1) test
       test something 2:
     Uncaught Cannot accept dialog which is already handled!
      at Object.assert (node_modules/puppeteer/lib/cjs/puppeteer/common/assert.js:26:15)
      at Dialog.accept (node_modules/puppeteer/lib/cjs/puppeteer/common/Dialog.js:79:21)
      at /home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/node_modules/codeceptjs/lib/helper/Puppeteer.js:483:25
  
  Scenario Steps:
  - I.amOnPage("https://example.com") at Test.<anonymous> (./test_test.js:9:7)
  

  2) test
       test something 2:
     Error: done() called multiple times in test <test: test something 2> of file /home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/test_test.js
      at /home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/node_modules/codeceptjs/lib/scenario.js:99:41


  FAIL  | 1 passed, 2 failed   // 1s
Run with --verbose flag to see complete NodeJS stacktrace

Provide test source code if related

<script>
    window.addEventListener("beforeunload", function(event) {
        event.returnValue = "message";
    });
</script>
Feature('test');

Scenario('test something', ({ I }) => {
    I.amOnPage(`file://${process.cwd()}/test.html`);
});


Scenario('test something 2', ({ I }) => {
    I.amOnPage('https://example.com');
});
Details
  • CodeceptJS version: 3.1.2
  • NodeJS Version: v16.9.1
  • Operating System: macOS | Linux
  • puppeteer: 10.4.0
  • Configuration file:
const { setHeadlessWhen } = require('@codeceptjs/configure');

// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

exports.config = {
  tests: './*_test.js',
  output: './output',
  helpers: {
    Puppeteer: {
      restart: false,
      url: 'http://localhost',
      show: false,
      windowSize: '1200x900'
    }
  },
  bootstrap: null,
  mocha: {},
  name: 'puppeteer-test',
  plugins: {
    pauseOnFail: {},
    retryFailedStep: {
      enabled: true
    },
    tryTo: {
      enabled: true
    },
    screenshotOnFail: {
      enabled: true
    }
  }
}
Lingua principale
JavaScript
Stelle
4.2k
Fork
756
Merge medio
2g 9h
PR unite (30g)
16

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codeceptjs/CodeceptJS

Tutte le issue di codeceptjs/CodeceptJS

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.