If it possible in Cypress.io to save data in variables and reuse it in other block
For example, I have a special name of device. I want to recieve this data and after clicking on it, check if title in new window contains that special name of device
I know how it make with static name, but I try to create dunamic autotest and I wanted to know if it possible
2
Answers
I have a feeling there is already an answer to this, but could not find one that is generally applicable.
Maybe a good approach is to use cypress-data-session. There is a lot of documentation but here is a sample usage:
Another option I have seen is using the Cypress environment as a data store.
The downside IMO is – it’s not elegant to use
Cypress.env()
everywhere, and it can lose the values if Cypress browser resets.Just put a const/var/let infront of all your test on the top and give it no value. in your test u can just give it an value and use it elsewhere in another test
For example like this