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

feat: Allow user to set browser preferences #247

Merged
merged 2 commits into from
Sep 14, 2021

Conversation

christian-bromann
Copy link
Contributor

implements: #213

In WebdriverIO we offer to run automated browser tests using WebDriver or CDP (via Puppeteer). When we start a Puppeteer browser we use this package as it gives us more options to set the browser session. However it is not possible to set a custom set of browser preferences, e.g. to define the default download directory. This patch adds this capability to the package. To create feature parity given that Chromedriver allows this, it would be great if we could add this.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

src/chrome-launcher.ts Outdated Show resolved Hide resolved
src/chrome-launcher.ts Outdated Show resolved Hide resolved
src/chrome-launcher.ts Outdated Show resolved Hide resolved
@christian-bromann christian-bromann force-pushed the cb-set-prefs branch 3 times, most recently from 9b29a4e to 1a6fea4 Compare September 7, 2021 17:17
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM when tests pass, thanks! :)

test/chrome-launcher-test.ts Outdated Show resolved Hide resolved
src/chrome-launcher.ts Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@christian-bromann
Copy link
Contributor Author

Is there anything else I can do?

@patrickhulce
Copy link
Collaborator

you just did it (a reminder when the tests pass 😉 )

thanks @christian-bromann!

@patrickhulce patrickhulce merged commit 630bb77 into GoogleChrome:master Sep 14, 2021
@christian-bromann christian-bromann deleted the cb-set-prefs branch September 14, 2021 15:47
@NavyMint
Copy link

NavyMint commented Oct 6, 2021

Hi guys. @patrickhulce @paulirish sorry for disturbing you, do you guys know when we can expect this feature to be released?

@patrickhulce
Copy link
Collaborator

@NavyMint PR is up for release :) #249

@NavyMint
Copy link

NavyMint commented Oct 6, 2021

@NavyMint PR is up for release :) #249

thank you :) @patrickhulce

@paulirish
Copy link
Member

@christian-bromann this preference file thing.. works, right?
We've never used this technique, but if it works for you, that's great to hear. :)

@christian-bromann
Copy link
Contributor Author

@paulirish I tried to verify and it seems to not work anymore. Launching Chrome as following:

"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary" --remote-debugging-port=61586 --user-data-dir=/var/folders/3_/pzc_f56j15vbd9z3r0j050sh0000gn/T/lighthouse.XXXXXXX.cofPsDof --enable-automation --disable-popup-blocking --disable-extensions --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-sync --metrics-recording-only --disable-default-apps --mute-audio --no-first-run --no-default-browser-check --disable-hang-monitor --disable-prompt-on-repost --disable-client-side-phishing-detection --password-store=basic --use-mock-keychain --disable-component-extensions-with-background-pages --disable-breakpad --disable-dev-shm-usage --disable-ipc-flooding-protection --disable-renderer-backgrounding --force-fieldtrials=*BackgroundTracing/default/ --enable-features=NetworkService,NetworkServiceInProcess --disable-features=site-per-process,TranslateUI,BlinkGenPropertyTrees --window-position=0,0 --window-size=1200,900 --auto-open-devtools-for-tabs --window-size=1600,1200 about:blank

While having a pref file written at /var/folders/3_/pzc_f56j15vbd9z3r0j050sh0000gn/T/lighthouse.XXXXXXX.cofPsDof/Preferences with the contents of

{
    "devtools.preferences.currentDockState": "\"bottom\"",
    "devtools.preferences.splitLocation": "\"50%\"",
    "devtools.preferences.panel-selectedTab": "\"console\""
}

Does not to have any effect anymore.

@Junyan
Copy link
Contributor

Junyan commented Aug 8, 2023

@christian-bromann Try setting it to this file: /var/folders/3_/pzc_f56j15vbd9z3r0j050sh0000gn/T/lighthouse.XXXXXXX.cofPsDof/Default/Preferences

This is a demo.
259123284-2c0129ba-6e91-4131-bfb2-19c63992912c

@paulirish
Copy link
Member

@christian-bromann yeah i think you're missing the /Default/ in the pref file path. I just tried this out and it seems to work.

@christian-bromann
Copy link
Contributor Author

Thanks @paulirish , I will look into raising a PR with a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants