'Expect' assertion to check the element's absence doesn't work #14648
-
hi, i have created custom commands for existence assertion using .expect() Below is the command sample: then i use it like below now, it works correctly when 'exist' is true but it fails when 'exist' is false. AssertionError my concern is, this element is not gonna be exist in the DOM and i am already asserting that the element is not exist, then why is it failing with the reason as "Timed out retrying"? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The |
Beta Was this translation helpful? Give feedback.
-
Perfect
…Sent from my iPhone
On Jan 20, 2021, at 11:02, sureshautomation ***@***.***> wrote:
just an update.
i have update then(e) with should(e), then it is working as expected and no timeout error shown.
cy.xpath(element, {timeout: wait}).should((e) => {
expect(e, elementName).not.to.exist;
});
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Beta Was this translation helpful? Give feedback.
The
cy.xpath
already checks if the element exists, thus by the time you get the element it is too late. You might want to write your own xpath command this such option following the blog post https://glebbahmutov.com/blog/writing-custom-cypress-command/