0

Hi have this code and i want to assert the $element if visible or not visible. How can i do it? i tried should and expect but its failing

 cy.get('.cloudfront_new_header').then(($element) => {
   if ($element.style.visibility = "hidden"){
     cy.log('Visible')
   } else { 
     cy.log('NotVisible')
   }
 })
Fody
  • 23,754
  • 3
  • 20
  • 37
Noel Dulin
  • 321
  • 1
  • 3
  • 12

1 Answers1

1

You have to use the Jquery method is(':visible') for this.

cy.get('.cloudfront_new_header').then(($ele) => {
  if ($ele.is(':visible')) {
    cy.log('Visible')
  } else {
    cy.log('NotVisible')
  }
})
Alapan Das
  • 17,144
  • 3
  • 29
  • 52