Join Discord
Powered by
Hey <@995618594090123274> , as for custom commands...
# help
h
high-shampoo-86680
07/11/2022, 6:19 PM
Hey
@elegant-river-87347
, as for custom commands with multiple parameters, Cypress has a whole page on such which I recommend, but this example specifically shows what that looks like:
https://docs.cypress.io/api/cypress-api/custom-commands#Download-a-file
But it seems like your question/problem isn't with that, it's with variable contexts. For that I recommend this entire page:
https://docs.cypress.io/guides/core-concepts/variables-and-aliases
. But specifically, what you're probably looking for is using an alias to store a value to be used later:
https://docs.cypress.io/guides/core-concepts/variables-and-aliases
Personally, I like using aliases with the
cy.get()
syntax instead of
this
. But you can always have a custom command return a value and access that value with
.then
or store it for later on in your test with
.as
as the articles show
Previous
Next