https://cypress.io logo
Changing browser flags during cypress run
# i-need-help
a
Hi, I have two spec files. For one I need to run --autoplay-policy=user-gesture-required chrome flag, for other --autoplay-policy=no-user-gesture-required. Currently handling it by running cypress run two times with different sets of flags, but there are some CI issues because of that, that I want to avoid. Is it possible to somehow change these flags during cypress run?
t
I've used Jenkins, TeamCity, and Gitlab for CI and I don't think I've ever seen a case of being able to pass in different params like that in the browser mid-test-run. At the start of each spec file could you possibly just navigate to "chrome://flags" and use cypress to check the policy option changes you need within the browser itself? Might not be the most elegant solution, but in keeping with best-practices this would mean each test sets itself into a known state before running, which is inherently more reliable. I am pretty sure it's not programmatically possible to change flags without doing it directly in the browser as a user would.
a
@thousands-house-85089 Before Cypress 10 browsers were reopened for each spec file, so there was a possibility to change some of the flags based on the spec name mid-test-run from before:browser:launch event(https://docs.cypress.io/api/plugins/browser-launch-api). Now the Cypress logic changed and it is not working anymore. Sadly variant with "chrome://flags" is not applicable to my situation. I need to run tests on multiple browsers, so need some kind of cross-browser solution, ideally cypress implementation (and chrome://flags doesn't have needed flags).
@best-flower-17510 Hey, maybe you could help somehow with the task?
b
it might be easier to solve the CI issues to be honest - since it's almost like cross-browser testing (just in this case it's the same browser, with different configs). might be useful to share some insight into the CI issues you're running into?/
a
@bland-salesclerk-62828 The main issue is too many CI jobs to maintain, tbh. Already went with that route, as didn't find any way to implement browser flag switching during the cypress mid-run 😔
3 Views