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

if command doesn't work if it is used after .find command #32

Closed ninadkambli closed 2 years ago

ninadkambli commented 2 years ago

Hi @bahmutov, I have written a below code in spec.cy.js

  1. import'cypress-if'
  2. context('Querying', () => {
  3. beforeEach(() => {
  4. })
  5. // The most commonly used query is 'cy.get()', you can
  6. // think of this like the '$' in jQuery
  7. it('cy.get() - query DOM elements', () => {
  8. cy.visit('https://example.cypress.io/commands/traversal')
  9. cy.get('.traversal-pagination').find('ls').if('not.exist').find('li').find('a').should('have.length', 7)
  10. })
  11. })

at line number 14 cypress is throwing an error Timed out retrying after 4000ms: Expected to find element: ls, but never found it. Queried from element: instead it should return cy.get('.traversal-pagination').finf('li').find('a') which is there in the DOM

github-actions[bot] commented 2 years ago

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

The release is available on:

Your semantic-release bot :package::rocket: