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

Passing custom Chrome profile directory (user data dir) not working on Mac and Linux #18308

Open
AJM-v opened this issue Sep 30, 2021 · 12 comments
Labels
browser: chrome prevent-stale mark an issue so it is ignored by stale[bot] stage: needs investigating Someone from Cypress needs to look at this type: unexpected behavior User expected result, but got another

Comments

@AJM-v
Copy link

AJM-v commented Sep 30, 2021

Current behavior

We would like to use a custom Chrome profile directory for our Cypress tests. The application we are testing uses a Web SQL database which needs to be loaded into the Chrome browser. We tried this command which should be a valid chromium argument.

launchOptions.args.push('--user-data-dir=/Users/testuser/dev/chrome')

But when we run Cypress we see that the Chrome Profile Path is being overwritten by Cypress:

image

Desired behavior

The Chrome Profile Path from the launchOptions '--user-data-dir=/Users/testuser/dev/chrome' is used.

Test code to reproduce

Our setup:

  • MacOs
  • Chrome v93
  • Cypress v8.4.0

The code we tried in our index.js (plugins folder):

module.exports = (on, config) => {
  
  on('before:browser:launch', (browser = {}, launchOptions) => {

    launchOptions.args.push('--user-data-dir=/Users/testuser/dev/chrome')

    launchOptions.args.push('--auto-open-devtools-for-tabs')
  
    return launchOptions
  })

};

Steps to reproduce:

  1. Add launchOptions argument with --user-data-dir like mentioned above
  2. Open Cypress dashboard (npx cypress open)
  3. Run 1 test in Chrome
  4. Chrome browser opens, type chrome://version in URL bar
  5. --user-data-dir=/Users/testuser/dev/chrome is listed in the Command Line panel, but I also see --user-data-dir=/Users/xxxxx/Library/Application Support/Cypress/cy/production/browsers/chrome-stable/interactive listed, and that is the Profile Path which is being used by Cypress

Cypress Version

8.4.0

Other

Also tested on a Windows 10 environment and there this code is working fine when testing headed in Chrome.

@AlexMurphy
Copy link

@AJM-v Did you find a solution to this?

We have a use case that also requires custom Chrome profiles,

@AJM-v
Copy link
Author

AJM-v commented Nov 10, 2021

@AJM-v Did you find a solution to this?

We have a use case that also requires custom Chrome profiles,

@AlexMurphy
Nope, our dev team is creating a workaround for the app we are testing so that we don't have to use a custom chrome profile.

@lughino
Copy link

lughino commented Nov 28, 2021

Same issue here on mac.
Cypress team could you have a look please?

@mike1936
Copy link

Same issue on Windows, both --user-data-dir and --remote-debugging-port settings are overwritten.

@lucassardois
Copy link

This issue still happen on cypress version 12 when using the run command from the CLI such as npx cypress run --headed --no-exit --browser chrome. I guess it's because when we run cypress it generate a new temp chrome profile to make the test isolated and this override this setting.

Is there any workaround?

@zapplebee
Copy link

I can tell that Cypress is intentionally overwriting this arg here.

https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/browsers/chrome.ts#L692

But there seems to be no escape hatch to chose it yourself.

@PK-Tests
Copy link

Our case also requires this approach (we are setting up mic permissions before test).
I tried running this in plugins/index.js:

export default (on, config) => {
    on('before:browser:launch', (browser = {}, launchOptions) => {
        launchOptions.args.push('--user-data-dir=../chromeProfile/Default');
    })
}

@mike-plummer mike-plummer removed their assignment Jul 5, 2023
@kaviththiranga
Copy link

We have the same requirement. We are trying to run VSCode (Electron) with cypress and we need to override --user-data-dir

@jennifer-shehane jennifer-shehane added type: unexpected behavior User expected result, but got another stage: needs investigating Someone from Cypress needs to look at this browser: chrome labels Dec 19, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Jun 16, 2024
@drptbl
Copy link

drptbl commented Jun 21, 2024

This issue is a blocker for many things for us and it's still occurring.

@jennifer-shehane jennifer-shehane added prevent-stale mark an issue so it is ignored by stale[bot] and removed stale no activity on this issue for a long period labels Jun 21, 2024
@jennifer-shehane
Copy link
Member

We did add an option recently to IGNORE_CHROME_PREFERENCES. You can see the code path here: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/browsers/chrome.ts#L111C19-L111C44

I haven't tried this specific use case, but it may be an option to opt out of the overwriting behavior that is causing problems with Cypress overwriting. Interested to hear if that works for anyone.

@matstyler
Copy link

We did add an option recently to IGNORE_CHROME_PREFERENCES. You can see the code path here: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/browsers/chrome.ts#L111C19-L111C44

I haven't tried this specific use case, but it may be an option to opt out of the overwriting behavior that is causing problems with Cypress overwriting. Interested to hear if that works for anyone.

I can confirm It doesn't work. Cypress still overwrites the --user-data-dir argument even with IGNORE_CHROME_PREFERENCES set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser: chrome prevent-stale mark an issue so it is ignored by stale[bot] stage: needs investigating Someone from Cypress needs to look at this type: unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests