-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
API to set chromium preferences #3671
Comments
Chromium code using prefs: https://chromium.googlesource.com/chromium/src/+/master/chrome/common/pref_names.cc#1427 |
Is this ready yet? |
Is it a thing? The prompt disabling is crucial ._ . |
I just dived a little bit through the cypress code and in my opinion we could add a plugin event similar to It could be executed somewhere around here: cypress/packages/server/lib/browsers/chrome.coffee Lines 281 to 290 in a877474
The code for reading and writing the profile can be found here: cypress/packages/server/lib/browsers/chrome.coffee Lines 137 to 146 in a877474
@jennifer-shehane any thoughts on it? We can also discuss it in gitter, before I would start with a small PoC pull request. |
I use this work-around currently. I haven't tried a persistent
#!/usr/bin/env bash
USER_DATA_DIR=`cut -d "=" -f 2 <<< ${*: -2:1}`
mkdir $USER_DATA_DIR/Default > $USER_DATA_DIR/Default/Preferences
cat << END_Preferences > $USER_DATA_DIR/Default/Preferences
{
"profile":{"content_settings":{"exceptions":{"cookies":{"example.com,*":{"setting":1}}}}},
"devtools":{"preferences":{"currentDockState":"\"undocked\"","panel-selectedTab":"\"sources\"","Inspector.drawerSplitViewState":"{\"horizontal\":{\"size\":0,\"showMode\":\"Both\"}}"}},
"browser":{"app_window_placement":{"DevToolsApp":{"maiximized": true}}}
}
END_Preferences
exec chromium $@ |
@nmschulte Your way doesn't work, because cypress is creating an own user data dir during startup. Another way would be to have access on the Chrome Debugging Protocol. @jennifer-shehane Do you know if there is any possibility to get the current connection? |
@CSchulz you are able to make a connection to the Chrome DevTools Protocol in |
@flotwig Thanks for your input! I will try it, but it seems Electron doesn't use anything like that, right? |
@CSchulz ah yes, good point, this will only work for Chrome-family browsers. To clarify, are you asking for CDP access from your tests, or from your pluginsfile? |
@flotwig I want to use it in the plugins file but it seems not working, because the browser is launched after the complete event handling. Using timeout seems a little bit hacky. |
@CSchulz I agree, it is a little bit hacky, right now that's the only way to do it unfortunately. I wrote a plugin that does a retry loop on |
@CSchulz it works for me; Chromium from Debian Sid. Chromium loads the Preferences stored in the specified dir; pressing F12 loads the dev tools in a separate window.
@flotwig does the Chrome DevTools Protocol allow to change the browser settings? https://stackoverflow.com/questions/57498081/chrome-devtools-protocol-interact-with-settings |
@nmschulte Yes you are right, it is using the same one for interactive mode, you can see it in the process explorer. The chrome driver overwrites the user-data-dir always: cypress/packages/server/lib/browsers/chrome.coffee Lines 284 to 308 in a3265cc
To your question you can change all the settings via chrome debug protocol: |
Setting Chromium preferences was releasedin #6293 in Cypress 4.0.0. You can find the new documentation on how to do this in: http://on.cypress.io/browser-launch-api @bkucera @flotwig I'd love if one of you could provide an example of how to pass the preferences for the scenarios above. I'm not really sure what the original
|
see an example for setting the default download location here #6494 currently it will not work with |
Current behavior:
We can't specify chromium preferences when running Cypress tests.
This becomes an issue when tests require certain browser configuration which is different to the defaults.
An example is to disable the popup dialog for file downloads (requires
download.prompt_for_download = true
).See more preferences in the link in this comment: #433 (comment)
Desired behavior:
A Cypress API to enable setting chromium preferences as key value pairs.
This could be a new API or an extension to one of the existing APIs such as the browser-launch-api or the configuration-api.
Versions
Valid for both Chrome and Electron setups.
The text was updated successfully, but these errors were encountered: