How to Get all IDs for the sessions created using cy.session() #19871
-
Hello, I would need to access all the IDs of the sessions created using cy.session() via the code. As this is already being done in the "time travel" logs, I assume this is somehow accessible, but I could not find a way to do it. Could you please share any input on this? Thank you, Alex |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Some quick digging in the code and this was easy enough to find. For reference to anyone looking for this, you can get all active sessions by using the function cy.state('activeSessions') Afterwards you can easily play with it to retrieve the data that you want:
or better
or anything else you might be needing. Note that if you are using Typescript, you will need to @ts-ignore the cy.state() function, as this is not exposed. |
Beta Was this translation helpful? Give feedback.
-
Added a feature request for this too, in order to make this available for use in the code and not have it hidden + add documentation in the Cypress docs. |
Beta Was this translation helpful? Give feedback.
Some quick digging in the code and this was easy enough to find.
For reference to anyone looking for this, you can get all active sessions by using the function
cy.state('activeSessions')
Afterwards you can easily play with it to retrieve the data that you want:
or better
or anything else you might be needing.
Note that if you are using Typescript, you will need to @ts-ignore the cy.state() function, as this is not exposed.