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

[Bug]: Codecept with Playwright e2e tests throws connection refused error in Github Actions #3361

Closed
RashmiRamdas opened this issue Jul 14, 2022 · 10 comments

Comments

@RashmiRamdas
Copy link

RashmiRamdas commented Jul 14, 2022

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
        }
    },
};
@kobenguyent
Copy link
Collaborator

perhaps the url is not proper? http://localhost:3000/ instead of https

@RashmiRamdas
Copy link
Author

RashmiRamdas commented Jul 15, 2022

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 microsoft/playwright#15642 for this issue. They have confirmed its related to codecept module as there is no Playwright._after in the stock Playwright library.

@DavertMik
Copy link
Contributor

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

@coskunuyar
Copy link

Same issue with bitbucket pipelines

@mosaadm
Copy link

mosaadm commented Oct 31, 2022

any updates on this ?

@Emad-Armoun
Copy link

Are there any updates on this?

@achisholm
Copy link

Arrived here via microsoft/playwright#15642. I'm experiencing this same issue on playwright v1.29.2 when I run a github action

@AyoCodess
Copy link

any updates, we have the same issue in GitHub actions only. everything works well locally

@coskunuyar
Copy link

my action is giving up on playwright :)

@kobenguyent
Copy link
Collaborator

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.

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

No branches or pull requests

8 participants