[Bug]: Codecept with Playwright e2e tests throws connection refused error in Github Actions
I'm trying to run e2e tests in parallel with workers (run-workers) in Github Actions in headless mode and getting this error
browserContext.storageState: net::ERR_FAILED at https://localhost:3000/ at Playwright._after Some of the tests run successfully before throwing this error. I have observed this error only on Github Actions and works fine on local
browserContext.storageState: net::ERR_FAILED at https://localhost:3000/
at Playwright._after (/data/runners/node_modules/codeceptjs/lib/helper/Playwright.js:434:50) {
name: 'Error'
}
Click on close icon in nav bar when the form is in dirty state then Save the changes- Crystal
--- STARTED "before each" hook: Before for "Click on close icon in nav bar when the form is in dirty state then Save the changes- Crystal" ---
I clear cookie
› Screenshot is saving to /data/runners/test/output/record_2ade0e9c5f1ca5cebfabd11e1e1ae3fa/0000.png
I am on page "/home"
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
› Screenshot is saving to /data/runners/test/output/record_2ade0e9c5f1ca5cebfabd11e1e1ae3fa/0001.png
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
[1] Error | Error: page.goto: net::ERR_CONNECTION_REFUSED at https://localhost:3000/showcase/home
=========================== logs ===========================
navigating to "https://localhost:3000/showcase/home", waiting until "networkidle"
============================================================
[1] <teardown> Stopping recording promises
✖ FAILED in 212ms
Details
- CodeceptJS version: 3.2.3
- NodeJS Version: 14
- Operating System: Linux
- playwright: 1.18.0
- Configuration file:
const { setHeadlessWhen, setWindowSize } = require("@codeceptjs/configure");
const { integration } = require(`./../package.json`);
const page = require("./utils/pageObject");
const bootstrap = require("./utils/boostrap");
const users = require("./utils/users");
setHeadlessWhen(process.env.CI || integration.headless);
setWindowSize(1920, 1080);
exports.config = {
tests: `./**/*.+(e2e|visual).+(js|ts)`,
output: `./output`,
helpers: {
Playwright: {
url: process.env.SHOWCASE_URL || integration.url || "https://localhost:3000/showcase",
browser: process.profile || integration.browser || "chromium",
show: !integration.headless,
coloredLogs: true,
smartWait: integration.waitInSeconds * 1000 || 5 * 1000,
uniqueScreenshotNames: true,
fullPageScreenshots: true,
restart: false,
keepBrowserState: true,
keepCookies: true,
waitForNavigation: "networkidle0",
timeouts: {
script: 60000,
"page load": 10000,
},
ignoreHTTPSErrors: true,
chromium: {
args: [
"--disable-web-security",
"--allow-insecure-localhost",
"--ignore-certificate-errors",
"--no-sandbox",
"-–allow-file-access-from-files",
],
},
firefox: {
args: [
"--disable-web-security",
"--allow-insecure-localhost",
"--ignore-certificate-errors",
"--ignore-ssl-errors",
"--no-sandbox",
"-–allow-file-access-from-files",
],
},
},
Actions: {
require: "./utils/helpers/actionsHelper.js",
},
},
include: {
I: "./utils/customSteps.js",
Selectors: "./utils/pageObject",
},
multiple: {
e2e: {
browsers: [{ browser: "firefox" }, { browser: "chromium" }],
},
},
bootstrap: bootstrap,
mocha: {},
name: "showcase",
plugins: {
retryFailedStep: {
enabled: true,
},
stepByStepReport: {
enabled: true,
},
screenshotOnFail: {
enabled: false,
},
customLocator: {
enabled: true,
prefix: "testid=",
attribute: "data-testid",
},
allure: {
enabled: false,
enableScreenshotDiffPlugin: false,
},
autoLogin: {
enabled: true,
saveToFile: true,
inject: "loginAs",
users: users,
},
stepTimeout:{
enabled: true,
timeout: 10
}
},
};
perhaps the url is not proper? http://localhost:3000/ instead of https
URL is correct, it is https://localhost:3000/showcase. Some of the tests pass with this config and some random tests fails with above error.
Also, created ticket with playwright https://github.com/microsoft/playwright/issues/15642 for this issue. They have confirmed its related to codecept module as there is no Playwright._after in the stock Playwright library.
Is this still valid?
// close other sessions
try {
const contexts = await this.browser.contexts();
const currentContext = contexts[0];
if (currentContext && (this.options.keepCookies || this.options.keepBrowserState)) {
this.storageState = await currentContext.storageState();
}
await Promise.all(contexts.map(c => c.close()));
} catch (e) {
console.log(e);
}
// await this.closeOtherTabs();
return this.browser;
Currently all storageState activity is wrapped in try/catch block
Same issue with bitbucket pipelines
any updates on this ?
Are there any updates on this?
Arrived here via https://github.com/microsoft/playwright/issues/15642. I'm experiencing this same issue on playwright v1.29.2 when I run a github action
any updates, we have the same issue in GitHub actions only. everything works well locally
my action is giving up on playwright :)
Closed for now! Feel free to reopen if you still encounter the issue with latest version and would be nice to provide a sample code to reproduce the issue.