Cannot access nested values in Cypress.json file.
I have just started learning Cypress and trying to organise some variables into the Cypress.json file.
The usual dot and bracket notation do not work because the key is already in single/double quotes, so I think Cypress sees it as a complete string eg. (Cypress.env('login.username'))
.
This is my simple Cypress.json file
{
"env":{
"login":{
"username":"Joe"
}
}
}
How can I access the name Joe
?
Try this, it will return the username.
Cypress.env('login').username // returns "Joe"
Read more about Environment Variables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With