cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.01k stars 3.18k forks source link

If pass browser edge as a parameter the connection returns timeout #29819

Open lhidalgomqa opened 3 months ago

lhidalgomqa commented 3 months ago

Current behavior

  1. Initialized a Cypress proyect.
  2. Use a basic example test.
  3. Install cross-env to use several envs and browsers. (https://www.npmjs.com/package/cross-env).
  4. Put in "package" < "scripts" the following script:
    "cy:test:01": "cross-env npm_config_test_browser=%npm_config_test_browser% npm_config_env=%npm_config_env% npx cypress run --spec \"cypress/e2e/name-example-test.cy.js\" --browser %npm_config_test_browser% --env environmentName=%npm_config_env%"
  5. Add in the script the test exactly (in name-example-test.cy.js).
  6. Put in the cypress.config.js the following code:
      // Environments configuration
      // Pre is the default environment
      const environmentName = process.env.ENV || "pre"; // Default to "pre" if ENV is not set
      const environmentFilename = path.resolve(__dirname, `${environmentName}.settings.json`);
      console.log("Loading %s", environmentFilename);
      try {
        const settings = require(environmentFilename);
        if (settings.baseUrl) {
          config.baseUrl = settings.baseUrl;
        }
        if (settings.env) {
          config.env = {
            ...config.env,
            ...settings.env,
          };
        }
        console.log("Environment settings loaded successfully.");
      } catch (error) {
        console.error("Error loading environment settings:", error);
      }
      // Browser configuration
      const browserName = process.env.BROWSER || "chrome"; // Default to "chrome" if BROWSER is not set
      console.log("Using browser: %s", browserName);
      config.browser = browserName;
      return config;
    }
  7. Creates 3 json files: pre.settings.json / dev.settings.json / prod.settings.json with the following scheme:
    {
        "baseUrl": "",
        "env": {}
    }
  8. Executes in a new command line the following commands(use windows commands): first:
    $env:npm_config_test_browser = "edge"

    second:

    $env:npm_config_env = "pre"

    third:

    npm run cy:test:01
  9. Check if the run executes the test with "edge" and "pre".

Problem 1: returns an error:

Still waiting to connect to Edge, retrying in 1 second (attempt 18/62)
Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 50 seconds.

This usually indicates there was a problem opening the Edge browser.

The CDP port requested was 59155.

Error: connect ECONNREFUSED 127.0.0.1:59155
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)

Problem 2: If you put in BROWSER = "firefox" doesn't recognize the browser.

Desired behavior

  1. Cypress should executes the test with edge.

Test code to reproduce

try to execute the steps.

Cypress Version

14.12.0

Node version

20.14.0

Operating System

windows 10

Debug Logs

PS C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter> set DEBUG=cypress:*
PS C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter> $env:npm_config_test_browser = "edge"
PS C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter> $env:npm_config_env = "pre"
PS C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter> npm run cy:test:01

> framework-cypress-base-multireporter@2.0.0 cy:test:01
> cross-env npm_config_test_browser=%npm_config_test_browser% npm_config_env=%npm_config_env% npx cypress run --spec "cypress/e2e/1_busqueda_guia_medica.cy.js" --browser %npm_config_test_browser% --env environmentName=%npm_config_env%

DevTools listening on ws://127.0.0.1:59722/devtools/browser/5cec4b25-3867-402e-974d-f3d40e09f56f
Loading C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter\pre.settings.json
Environment settings loaded successfully.
Using browser: electron

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        13.12.0                                                                        │
  │ Browser:        Edge 126 (headless)                                                            │
  │ Node Version:   v20.14.0 (C:\Program Files\nodejs\node.exe)                                    │
  │ Specs:          1 found (1_busqueda_guia_medica.cy.js)                                         │
  │ Searched:       C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter\cypress\ │
  │                 e2e\1_busqueda_guia_medica.cy.js                                               │
  │ Experiments:    experimentalInteractiveRunEvents=true,experimentalModifyObstructiveThirdParty… │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

The event 'before:run' has been activated correctly.
The folder C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter\cypress\resultados does not exist. No action has been taken.
The folder C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter\cypress\screenshots does not exist. No action has been taken.

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

  Running:  1_busqueda_guia_medica.cy.js                                                    (1 of 1)
Still waiting to connect to Edge, retrying in 1 second (attempt 18/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 19/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 20/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 21/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 22/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 23/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 24/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 25/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 26/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 27/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 28/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 29/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 30/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 31/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 32/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 33/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 34/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 35/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 36/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 37/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 38/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 39/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 40/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 41/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 42/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 43/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 44/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 45/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 46/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 47/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 48/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 49/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 50/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 51/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 52/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 53/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 54/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 55/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 56/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 57/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 58/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 59/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 60/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 61/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 62/62)
Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 50 seconds.

This usually indicates there was a problem opening the Edge browser.

The CDP port requested was 59740.

Error: connect ECONNREFUSED 127.0.0.1:59740
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)

Other

No response

lhidalgomqa commented 3 months ago

Possible Enhancement: Cypress should, when installing the cypress package, bring a browser kit with its installation. This kit would be with the main browsers. Currently this is done in playwright, both playwright and the browsers are installed and thus can be used in isolation with test automation. If we depend on the browsers installed on the machines, more problems occur. Thanks for your time.

jennifer-shehane commented 3 months ago

@lhidalgomqa We did have a proposal to include a browser kit, it would be quite a lot of work for us to implement.

Does the edge browser work if you just run cypress run --browser=edge by itself? or firefox? There are a lot of variables involved here, so it'd be ideal to narrow them down.

Also, what version of Cypress are you using? 14.12.0 is not a version that exists. Please make sure you're using the latest (13.13.0)

lhidalgomqa commented 3 months ago

Hello! if i try execute: npx cypress run --browser edge, returns:

PS C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter> npx cypress run --browser edge

DevTools listening on ws://127.0.0.1:60196/devtools/browser/c82f4a37-e64c-4381-bce8-7400f2fc4131
Loading C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter\pre.settings.json
Environment settings loaded successfully.
Using browser: chrome

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        13.12.0                                                                        │
  │ Browser:        Edge 126 (headless)                                                            │
  │ Node Version:   v20.14.0 (C:\Program Files\nodejs\node.exe)                                    │
  │ Specs:          3 found (1_busqueda_guia_medica.cy.js, 2_contratacion_poliza.cy.js, actions.cy │
  │                 .js)                                                                           │
  │ Searched:       cypress/e2e/*.{js,jsx,ts,tsx}                                                  │
  │ Experiments:    experimentalInteractiveRunEvents=true,experimentalModifyObstructiveThirdParty… │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

The event 'before:run' has been activated correctly.
The folder C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter\cypress\resultados does not exist. No action has been taken.
The folder C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter\cypress\screenshots does not exist. No action has been taken.

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

  Running:  1_busqueda_guia_medica.cy.js                                                    (1 of 3)
Still waiting to connect to Edge, retrying in 1 second (attempt 18/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 19/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 20/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 21/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 22/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 23/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 24/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 25/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 26/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 27/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 28/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 29/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 30/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 31/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 32/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 33/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 34/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 35/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 36/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 37/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 38/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 39/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 40/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 41/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 42/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 43/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 44/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 45/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 46/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 47/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 48/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 49/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 50/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 51/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 52/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 53/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 54/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 55/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 56/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 57/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 58/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 59/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 60/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 61/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 62/62)
Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 50 seconds.

This usually indicates there was a problem opening the Edge browser.

The CDP port requested was 52318.

Error: connect ECONNREFUSED 127.0.0.1:52318
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)

Cypress version: 13.12.0 

If i try to update cypress, after make the update to 13.13.0:

PS C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter> npx cypress run --browser edge
It looks like this is your first time using Cypress: 13.13.0

✔  Verified Cypress! C:\Users\lhidalgom\AppData\Local\Cypress\Cache\13.13.0\Cypress

Opening Cypress...

DevTools listening on ws://127.0.0.1:55346/devtools/browser/586b497f-6cfa-4cfc-9a34-e33ff1998c47
Loading C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter\pre.settings.json
Environment settings loaded successfully.
Using browser: chrome

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        13.13.0                                                                        │
  │ Browser:        Edge 126 (headless)                                                            │
  │ Node Version:   v20.14.0 (C:\Program Files\nodejs\node.exe)                                    │
  │ Specs:          3 found (1_busqueda_guia_medica.cy.js, 2_contratacion_poliza.cy.js, actions.cy │
  │                 .js)                                                                           │
  │ Searched:       cypress/e2e/*.{js,jsx,ts,tsx}                                                  │
  │ Experiments:    experimentalInteractiveRunEvents=true,experimentalModifyObstructiveThirdParty… │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

The event 'before:run' has been activated correctly.
The folder C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter\cypress\resultados does not exist. No action has been taken.
The folder C:\Users\lhidalgom\Documents\workspace\infra\mediadores-multireporter\cypress\screenshots does not exist. No action has been taken.

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

  Running:  1_busqueda_guia_medica.cy.js                                                    (1 of 3)
Still waiting to connect to Edge, retrying in 1 second (attempt 18/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 19/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 20/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 21/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 22/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 23/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 24/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 25/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 26/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 27/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 28/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 29/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 30/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 31/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 32/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 33/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 34/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 35/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 36/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 37/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 38/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 39/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 40/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 41/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 42/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 43/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 44/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 45/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 46/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 47/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 48/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 49/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 50/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 51/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 52/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 53/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 54/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 55/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 56/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 57/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 58/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 59/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 60/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 61/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 62/62)
Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 50 seconds.

This usually indicates there was a problem opening the Edge browser.

The CDP port requested was 55356.

Error: connect ECONNREFUSED 127.0.0.1:55356
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)

Could you please check if you replay the problem? Thanks :)

jennifer-shehane commented 3 months ago

Could you run Cypress in debug mode mode and print the entire set of logs here?