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

Allow to set Chrome preferences when running tests with Puppeteer #7351

Closed
christian-bromann opened this issue Aug 27, 2021 · 4 comments
Closed
Assignees
Labels
devtools DevTools protocol good first pick a reasonable task to start getting familiar with the code base help wanted Issues that are free to take by anyone interested

Comments

@christian-bromann
Copy link
Member

Is your feature request related to a problem? Please describe.
With the following test you are able to specify preferences, e.g. default download directory, in Chrome using WebDriver:

const { remote } = require('./packages/webdriverio')

let browser

const opts = {
    // automationProtocol: 'devtools',
    capabilities: {
        browserName: 'chrome',
        'goog:chromeOptions': {
            prefs: {
                'download.default_directory': __dirname
            }
        }
    }
}

;(async function () {
    browser = await remote(opts)
    await browser.url('https://the-internet.herokuapp.com/download')
    await browser.$("a[href*='some-file.txt']").click()
    await browser.deleteSession()
})().catch(async (e) => {
    console.error(e.stack)
    await browser.deleteSession()
})

The prefs property is not respected when starting sessions using Puppeteer.

Describe the solution you'd like
I would suggest to create a temporary directory with a preference file that contains these preferences. Then pass this directory as customDataDir to the launch method, like in this exampe. This should only happen if someone defines these prefs.

Describe alternatives you've considered
In WebDriver this obviously works already.

Additional context
Add any other context or screenshots about the feature request here.

@christian-bromann christian-bromann added help wanted Issues that are free to take by anyone interested good first pick a reasonable task to start getting familiar with the code base devtools DevTools protocol labels Aug 27, 2021
@yzvezdin
Copy link

Probably the dir with custom data file might be needed for some other cases either. As other proposed method by the link seems to redirect to a deprecated methods of Puppeteer :(
Also reviewed other links and no better solution still :( Even from the Puppeteer team.
Is that possible to be added to WDIO? Or we can utilize that ourselves somehow (as we don't have direct access to a puppeteer).

@christian-bromann
Copy link
Member Author

Is that possible to be added to WDIO?

What do you mean?

as we don't have direct access to a puppeteer

You do have access to the Puppeteer instance with getPuppeteer.

@yzvezdin
Copy link

Cool, will try. Thank you.

@christian-bromann christian-bromann self-assigned this Sep 6, 2021
@christian-bromann
Copy link
Member Author

This feature got implemented in chrome-launcher (GoogleChrome/chrome-launcher#247) and will be available once merged and released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devtools DevTools protocol good first pick a reasonable task to start getting familiar with the code base help wanted Issues that are free to take by anyone interested
Projects
None yet
Development

No branches or pull requests

2 participants