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

ignore defaultChromeFlags / PptrDefaultArgs tags #5344

Conversation

anemer
Copy link
Contributor

@anemer anemer commented May 1, 2020

Proposed changes

Added 2 optional parameters (in wdio.conf.js / capabilities) that allow:

  • to launch Google Chrome without the default flags (given in devtools)
  • and/or to launch browser without the default Puppeteer arguments

#5339

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

Reviewers: @webdriverio/project-committers

@jsf-clabot
Copy link

jsf-clabot commented May 1, 2020

CLA assistant check
All committers have signed the CLA.

@anemer
Copy link
Contributor Author

anemer commented May 1, 2020

Haha!

  • Jest: "global" coverage threshold for branches (96%) not met: 95.99%
  • Test Suites: 201 passed, 201 total
  • Tests: 1904 passed, 1904 total
  • Snapshots: 89 passed, 89 total
  • Time: 133.787s
  • Ran all test suites.

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use 1 parameter for both as they are essentially doing the same thing?

@anemer
Copy link
Contributor Author

anemer commented May 2, 2020

It's possible.
But what if someone wants to change some of default Chrome flags, but wants the default Puppeteer's arguments to be preserved (for Chrome or other browsers)?

@christian-bromann
Copy link
Member

The user would just need to set:

ignorePuppeteerDefaultArgs: {
   // default args to be ignored
   args: [...]
}

@anemer
Copy link
Contributor Author

anemer commented May 2, 2020

Ok. I will set a single parameter that affects the 2 lists of default args/flags.
It will be exactly like the Puppeteer's ignoreDefaultArgs parameter (same name, same type = <[boolean]|[Array]<[string]>>) , and its value will be passed to Puppeteer.

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move ignoreDefaultArgs into goog:chromeOptions as it i a custom capability?

packages/devtools/src/launcher.js Outdated Show resolved Hide resolved
Comment on lines 74 to 76
},
ignoreDefaultArgs ? { ignoreDefaultArgs: ignoreDefaultArgs } : {}
))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use Object.assign:

    const chrome = await launchChromeBrowser({
        chromePath: chromeOptions.binary,
        chromeFlags,
        ignoreDefaultArgs: Boolean(ignoreDefaultArgs)
    })

packages/devtools/src/launcher.js Outdated Show resolved Hide resolved
@@ -109,7 +120,8 @@ function launchBrowser (capabilities, product) {
width: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT
}
}, capabilities[vendorCapKey] || {})
}, capabilities[vendorCapKey],
ignoreDefaultArgs ? { ignoreDefaultArgs: true } : {})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above:

    const puppeteerOptions = Object.assign({
        product,
        executablePath,
        defaultViewport: {
            width: DEFAULT_WIDTH,
            height: DEFAULT_HEIGHT
        },
		ignoreDefaultArgs: Boolean(ignoreDefaultArgs)
    }, capabilities[vendorCapKey] || {})

Copy link
Contributor Author

@anemer anemer May 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move ignoreDefaultArgs into goog:chromeOptions as it i a custom capability?

It's true my first need was for Chrome. But:

  • As I can see in devtools/launcher.js devtools can also be used for other browsers than Chrome. Maybe not yet at the same level as with Chrome, but it's possible.

  • And it seems Puppeteer accepts this ignoreDefaultArgs parameter in its experimental support of Firefox (see experimental/puppeteer-firefox/Launcher.js).

so why limit this parameter only for Chrome?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above:

    const puppeteerOptions = Object.assign({
        product,
        executablePath,
        defaultViewport: {
            width: DEFAULT_WIDTH,
            height: DEFAULT_HEIGHT
        },
		ignoreDefaultArgs: Boolean(ignoreDefaultArgs)
    }, capabilities[vendorCapKey] || {})

line 124 is actually wrong. It should be like line 75:

    ignoreDefaultArgs ? { ignoreDefaultArgs: ignoreDefaultArgs } : {}

as ignoreDefaultArgs is either a boolean or a array of string (as in Puppeteer)

packages/devtools/src/launcher.js Outdated Show resolved Hide resolved
@@ -60,10 +62,13 @@ async function launchChrome (capabilities) {
}

log.info(`Launch Google Chrome with flags: ${chromeFlags.join(' ')}`)
const chrome = await launchChromeBrowser({

const chrome = await launchChromeBrowser(Object.assign({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still don't need Object.assign here if ignoreDefaultArgs can contain the same values as in Puppeteer we can just do:

const chrome = await launchChromeBrowser({
    chromePath: chromeOptions.binary,
    ignoreDefaultArgs,
    chromeFlags
})

@@ -109,7 +114,8 @@ function launchBrowser (capabilities, product) {
width: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT
}
}, capabilities[vendorCapKey] || {})
}, capabilities[vendorCapKey],
ignoreDefaultArgs ? { ignoreDefaultArgs: ignoreDefaultArgs } : {})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do the same here:

    const puppeteerOptions = Object.assign({
        product,
        executablePath,
        ignoreDefaultArgs,
        defaultViewport: {
            width: DEFAULT_WIDTH,
            height: DEFAULT_HEIGHT
        }
    }, capabilities[vendorCapKey] || {})

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these specific DevTools capabilities should be documented differently but since we don't have such a section yet I will approve this PR.

Thanks @anemer

@christian-bromann christian-bromann added the PR: Polish 💅 PRs that contain improvements on existing features label May 5, 2020
@christian-bromann christian-bromann merged commit a3428a6 into webdriverio:master May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Polish 💅 PRs that contain improvements on existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants