Cypress: Basic auth in baseUrl does not work in electron browser

Created on 25 Apr 2018  路  6Comments  路  Source: cypress-io/cypress

Current behavior:

If I have a baseUrl in cypress.json:

{
  "baseUrl": "http://username:[email protected]"
}

then a basic cypress run does not work. I get this error:

Timed out waiting for the browser to connect. Retrying...

This also happens if I run --headed.

It does work in latest Chrome (66).

Desired behavior:

It should open the page with basic auth data.

Steps to reproduce:

  1. Add baseUrl to cypress.json:
{
  "baseUrl": "http://username:[email protected]"
}
  1. Do cypress run

Versions

Cypress 2.1.0

duplicate

Most helpful comment

We ran into this issue in our project when updating Cypress from 1.4.2 to 2.1.0. There is a workaround based on (https://github.com/cypress-io/cypress/issues/1115).
We extended Cypress's visit command with:

Cypress.Commands.overwrite('visit', (orig, url, options) => {
  options = options || {};
  options.auth = {
    username: Cypress.env('AUTH_USER'),
    password: Cypress.env('AUTH_PASS')
  };
  return orig(url, options)
});

and we are running it with:

CYPRESS_AUTH_USER=user CYPRESS_AUTH_PASS=pass CYPRESS_baseUrl=https://app.com cypress run

All 6 comments

Important note: It works with the auth parameter in "cy.visit".

We ran into this issue in our project when updating Cypress from 1.4.2 to 2.1.0. There is a workaround based on (https://github.com/cypress-io/cypress/issues/1115).
We extended Cypress's visit command with:

Cypress.Commands.overwrite('visit', (orig, url, options) => {
  options = options || {};
  options.auth = {
    username: Cypress.env('AUTH_USER'),
    password: Cypress.env('AUTH_PASS')
  };
  return orig(url, options)
});

and we are running it with:

CYPRESS_AUTH_USER=user CYPRESS_AUTH_PASS=pass CYPRESS_baseUrl=https://app.com cypress run

Hello Cypress team!
It is there any information about a roadmap to fix this bug or something?

Cypress 3.1.4 seems to work ok on my Mac (at least with Chrome). However, this problem occurs when running Cypress 3.1.4 with Electron on cypress/base:10 Docker image (Debian + Node.js 10.13).

Basic auth seems to work ok, if you just don't set the baseUrl configuration parameter at all and you make the calls using a full url (e.g. cy.visit('https://user:[email protected]'). If you have set the baseUrl configuration parameter, Cypress probably gives that url to the browser even before the tests are run, and that time the timeout problem occurs. Even this dummy test fails to a connection timeout, if the baseUrl configuration parameter has been set:

describe('My First Test', function() {
  it('Does not do much!', function() {
    expect(true).to.equal(true)
  })
})

Actually the problem occurs also on Mac if you have set the baseUrl configuration parameter and choose Electron 56 as the browser. You wont see the same connection timeout error message, but you'll see that the browser won't load anything, it just stays blank. Try again with an undefined baseUrl and everything works ok. (Note that baseUrl must be undefined. Empty string as baseUrl won't work the same way.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbung picture rbung  路  3Comments

simonhaenisch picture simonhaenisch  路  3Comments

dkreft picture dkreft  路  3Comments

jennifer-shehane picture jennifer-shehane  路  3Comments

brian-mann picture brian-mann  路  3Comments