-
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
Proposal: Record open devTools in screenshots and video during cypress run
#2024
Comments
Chrome already has a flag to do this. So does electron. I suppose we could normalize this into a CLI argument perhaps - but users could already do this via the plugins API and modifying the launch args for chrome + for electron. |
Electron says that the option is https://github.com/cypress-io/cypress/blob/issue-4310/packages/server/lib/gui/windows.coffee#L142 WebPreferences logged at launch include no devTools {
partition: null,
chromeWebSecurity: true,
nodeIntegration: false,
backgroundThrottling: false
} Even so, when the option is So, I don't think this will work with Electron without some changes to Cypress. Workaround for ChromeAuto opening devTools within Chrome does work today with the following code in your You can run this with Since there is no video recording done with the chrome browser, using this flag for module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, args) => {
if (browser.name === 'chrome' || browser.name === 'chromium' || browser.name === 'canary') {
args.push('--auto-open-devtools-for-tabs')
return args
}
})
} |
There is no workaround for electron? |
@geralfonso There is, by setting on('before:browser:launch', (browser = {}, args) => {
if (browser.name === 'chrome') {
args = args.concat('--auto-open-devtools-for-tabs');
} else if (browser.name === 'electron') {
// Cypress-specific option (state)
args.devTools = true;
}
return args;
}); |
I could really do with this when I've tried @dwelle suggestion, but it doesn't work on 3.8.1. UPDATE: I've worked around it by using the suggested workarounds to print all console output to stdout. Now I can see the browser errors |
@mjlawrence83 can you post a link with that workaround? Thanks |
This is not quite right (or it's out of date), based on my testing. Here's what I have: on('before:browser:launch', (browser = {}, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
launchOptions.args.push('--auto-open-devtools-for-tabs');
} else if (browser.family === 'firefox') {
launchOptions.args.push('-devtools');
} else if (browser.name === 'electron') {
launchOptions.preferences.devTools = true;
}
return launchOptions;
}); |
Please can you tell me in which file I should update ,this commands. Can you provide with entire example with file name and file contents fully. |
1 similar comment
Please can you tell me in which file I should update ,this commands. Can you provide with entire example with file name and file contents fully. |
For electron, To open it, the documentation states that you need to call @mjlawrence83 , I have the same problem as you - a test that fails only in ci. 2 days on it already trying figure out how to open devtools or redirect output. How did you end up printing all console output to stdout? Cypress team - on behalf of myself and I'm sure many many others (saw quite a few related issues), it is very frustrating that easy access to console output to debug ci only problems is not part of the cypress core. |
This is now possible in all supported browsers with the workaround below. See https://on.cypress.io/browser-launch-api#Modify-browser-launch-arguments Closing as resolved. // plugins/index.js
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, launchOptions) => {
// `args` is an array of all the arguments that will
// be passed to browsers when it launches
console.log(launchOptions.args) // print all current args
if (browser.family === 'chromium' && browser.name !== 'electron') {
// auto open devtools
launchOptions.args.push('--auto-open-devtools-for-tabs')
}
if (browser.family === 'firefox') {
// auto open devtools
launchOptions.args.push('-devtools')
}
if (browser.name === 'electron') {
// auto open devtools
launchOptions.preferences.devTools = true
}
// whatever you return here becomes the launchOptions
return launchOptions
})
} |
@jennifer-shehane This only appears to work with the Cypress test runner, not when you run Cypress headlessly (as @mjlawrence83 and @rbabayoff mentioned above). IMO automatically opening devtools during Please advise. |
@jennifer-shehane we have the same use case as @mellis481 and @mjlawrence83, the logged Cypress error is basically useless in some cases for us, especially in async code. If we perform several API calls to set up our environment, sometimes we will just get a message that says basically just "500". We can't use cy.request because we need to use multiple results and we don't want to nest cy.request.thens. The stack traces are unhelpful, they don't point to the offending line of code, but instead point to some plumbing code like XHR. It would be so useful to just open the devtools and have them appear in the screenshots and recordings when running headless on our CI builds. I mean, it would be nicer if we could just have the error and stacktrace in the Cypress logs, but that seems unobtainable. So basically, our team has the same need as @mellis481 and @mjlawrence83, and we are looking for advice as well. |
+1 to that. Is there any way right now to access BrowserWindow from Cypress related code @jennifer-shehane? Thank you in advance |
cypress run
So, this option works when:
So you can see the devTools open while it runs. However, the video and screenshots are not capturing the devTools. So I think that is the more specific issue now, that the devTools panel needs to be captured in screenshots and videos so that it can be reviewed. As for printing the error that occurs in your devTools, this should be possible, similar to the https://github.com/flotwig/cypress-log-to-output plugin. If you create a task to console.log, you can print anything to the stdout. There's a few issues concerning this: #700 #300 |
cypress run
cypress run
For reference, this is what I was referring to when doing multiple The stacktrace reads:
Which is unhelpful as well. The various Cypress logging plugins we have found have trouble with reporting during If that screenshot and video could have had the devtools open, it would simplify our efforts to find the root cause of the actual 400 errors. Yes, we can examine the application logs from the container that was running during the tests, but it's a lot more effort than just getting a meaningful report of the error from the test itself. |
@jennifer-shehane is there any update on recording devTools during a headless |
Hey Cypress team!!! I would also love the ability to view devTools console logs from CI. Weirdly, while the above code does open devTools from the cypress open commend (locally), it actually HIDES the screenshots/recordings in cypress dashboard. Here is a screenshot from the cypress dashboard before trying to open dev tools. Here is after applying the above code to the plugins.js file. It actually removed the portion of the image with the browser + devTools, only showing the cypress console on left now. Very strange. This would be super helpful since it's complicated to perfectly test github actions locally. Thanks in advance! |
Found this after several days of trying to debug a ci only issue inside a container. Life is too short for this. |
Push... running in the same problem here. We need to take a look at the log's in CI run, but that seems not easy to handle |
would also like to see the dev console logs in videos for failures only seen running tests in CI - even if there's just a way to log those - that would be fine as well |
Or somehow dump the entire console log to a file we can inspect/upload as a CI artefact? |
+1 to this. We are looking forward to this feature as well. Any updates on this? |
I added the example from https://docs.cypress.io/api/plugins/browser-launch-api#Open-devtools-by-default and merely adding it as shown crashes Cypress with |
I've tried the same as Ansel and while my Cypress at least didn't crash, it didn't really work either. While Electron and Edge opened the dev tools on it's own as expected in Open mode, it was completely pointless for Runner mode. What I wonder about though, is whenever or not Cypress is just capturing the wrong area of the window, or if Edge is actively interferring on it's own for "security reasons". Electron on the other hand does not even care anymore in Runner mode and refuses to open the dev tools. And while it's nice not having to open dev tools each start of Cypress Open, this sadly doesn't do what it was actually intended for: include the console in failure screenshots... Edit: out of curiousity I've tried to enable |
I just upgraded to Cypress 13 and it seems like this ticket can now be closed because what is called out can be accomplished with Test Replay. 🎉 |
Closing this issue as we don't intend to extend the behavior of opening devtools during screenshots and videos in the future. Much of where Cypress is headed is in capturing the DOM, events, and debugging logs and allowing those to be replayed via Test Replay. You can see console logs, including errors that printed during your run and inspect them in your browsers devtools using it. Screenshots and videos were a great step for debugging beyond obtuse error messages of the past, but much of what it offers is flawed in its own ways, giving a limited view and lacking the real time exploration that Test Replay offers. Thanks for all of your feedback on this issue. 🙏🏻 |
Frankly, this is a bit disappointing to hear, but not surprising (given Cypress is a business). Cypress Cloud is cool, and Test Replay looks like useful functionality, but realistically, it's a paid feature, and the vast majority of people using Cypress are not paid customers. |
Not only that but I personally also don't see why I even need to involve the cloud when I have everything happening on my local workstation. If you're already running testing and building in the cloud, whatever. At that point it even makes sense. But for a local project? |
With these changes, it will no longer be possible to have opened the dev tools for electron in interactive mode and then have them automatically opened during a run. Also, it's never been possible to explicitly tells other browsers to open their dev tools.
Add a flag (
--dev-tools
or--open-dev-tools
) that will open the browser dev tools on launch so a debugger in test or app code can hit and pause the run for debugging purposes.The text was updated successfully, but these errors were encountered: