I'm still kinda new to Cypress, so please forgive any noob ignorance - but...
I'm using page objects, and trying to use a custom command that I've written as a kind of wrapper around assertions. This custom command will be used across a number of tests, and a number of page object files, so I don't want to replicate the code for it in each page object file. But! If I put the exact same code into the page object definition it works fine, if I use it as a custom command, the test hangs (elapsed time just goes up and up, but nothing happens)... A rough illustration of what I'm doing:
myPage.myFirstElement.click()
myPage.mySecondElement.type('something')
myPage.want(myPage.ThirdElement, 'to equal', 'Fred') // want is the name of my custom command / function in the PO file
The above works. However, if I move 'want' to a custom command:
myPage.myFirstElement.click()
myPage.mySecondElement.type('something')
cy.want(myPage.ThirdElement, 'to equal', 'Fred') // want is the name of my custom command / function in the PO file
This hangs, as described above. I've tried setting prevSubject in my custom command definition, to no avail. I've also tried using .then(...), also to no avail.
What am I failing to spot / understand correctly?
Thank you :)
Aucun commentaire:
Enregistrer un commentaire