Александр
Александр

Reputation: 317

How do I run a test with a Chrome profile(with arg '--user-data-dir') using Cypress?

I need to run auto tests with chrome browser profile. On selenium, I did it this way:

    let chromeOptions = new chrome.Options();
    chromeOptions.addArguments("--user-data-dir=/home/user/.config/google-chrome/Default");
    let driver = await new webdriver.Builder().forBrowser("chrome").setChromeOptions(chromeOptions).build();

How can I do this using cypress?

Upvotes: 4

Views: 3180

Answers (1)

Александр
Александр

Reputation: 317

You should add module.export before your code with browser profile path.

module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, launchOptions) => {
    launchOptions.args.push('--user-data-dir=/home/user/.config/google-chrome/Default')    
})
}
describe('My First Test', () => {
  it('Project', () => {
    cy.visit('https://project.com:8000/login')
    cy.log('successful sign in ')
  })
})

Upvotes: 0

Related Questions