bahmutov / cypress-if

Easy conditional if-else logic for your Cypress tests when there is no other way
https://cypress.tips/courses/cypress-plugins
99 stars 12 forks source link

Unable to use if('exist') in cy.xpath() #48

Closed naveensivakumar013 closed 2 years ago

naveensivakumar013 commented 2 years ago

I am trying to use cypress-if for validating whether the element is present or not using XPath. In some cases, it is hard to write CSS selectors as compared to XPath. Upon trying the same with XPath, we are getting 'element not found error' when it is not present, but it is working fine when it is present. Since the test case trying to achieve when the element is not found I need to update something else. Below is my sample code.

 cy.xpath(objects[page][locator]).if('exist').then(()=>{
                cy.log('locator Exists')
        }).else().then(()=>{
                cy.log('Locator Not Exists')
        })
github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 1.10.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: