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

Request issued by cy.request cannot be captured #59

Open
Kanapriya opened this issue Jul 15, 2021 · 5 comments
Open

Request issued by cy.request cannot be captured #59

Kanapriya opened this issue Jul 15, 2021 · 5 comments
Assignees
Labels
Priority: high Status: help wanted Extra attention is needed Type: enhancement New feature or request.

Comments

@Kanapriya
Copy link

In generated har file, couldn't see the request/data between a web browser and a web server (XHR) (access token endpoint request, scim endpoint and etc). Is this the limitation of this plugin?

Appreciate any input/workaround to capture the details of the xhr type of request in the har file.

@derevnjuk derevnjuk self-assigned this Aug 4, 2021
@derevnjuk derevnjuk added the Type: question Further information is requested label Aug 4, 2021
@Kanapriya
Copy link
Author

Any update on this question?
Is there any way to capture the xhr type of request in the .har file with this plugin?

@derevnjuk
Copy link
Member

@Kanapriya the plugin must capture all requests inside your browser session including those which have been sent by cy.request (see examples). Please provide a reproducible sample repo.

@pranavj1001
Copy link

Hey @derevnjuk, I've created a sample repo for your reference.

With the spec, you can see that I've made multiple cy.request requests but none of them were caught by the cypress-har-generator. I believe the reason behind this is that cypress doesn't make cy.request requests from the browser as mentioned here. Also, such requests are not available in the har file that was exported from the chrome browser.

My only question is, the har file generated by the chrome browser shows all the requests that were made during the session whereas the har file generated by cypress-har-generator shows the requests that were made during the last test of the spec. Why is this so?

@robbiewareham
Copy link

robbiewareham commented Oct 25, 2022

@pranavj1001 I am not a developer in this project but have written similar tools for other languages so have experience with the concepts. Hopefully the owners of this project won't mind me answering this question.

This plugin uses the Chrome DevTools Protocol (https://chromedevtools.github.io/devtools-protocol/) to subscribe to events triggered by chrome when HTTP requests are made and received. By keeping track of these events (there are multiple events associated to one request/response), a HAR file can be generated from the available data.

As a result, only requests made by the browser generate these events, hence requests made by the node process such as cy.request are not captured.

I guess that in theory as the process that is subscribing to the CDP events is the same process that makes the cy.request, a HAR file could be created that includes these also but they would have to be added to the HAR explicitly.

Whether it is possible for HAR generation code to access a log of cy.request, I don't know but would definitely be an enhancement request to this plug in.

Just to also say, there may be some confusion over the term XHR; my AUT makes many XHR requests after the page has finished loading and they are all captured.

cy.request is not an XHR as it is made by the node process not the browser

@aaujayasena
Copy link

xhr type request are available in the json file though it not display by importing any of the har file viewer. tried with chrome dev tools, and etc..

@derevnjuk derevnjuk changed the title 'xhr' type of request cannot be captured with this plugin Request issued by cy.request cannot be captured Jan 10, 2023
@derevnjuk derevnjuk added Type: enhancement New feature or request. Status: help wanted Extra attention is needed and removed Type: question Further information is requested labels Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: high Status: help wanted Extra attention is needed Type: enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

5 participants