Reputation: 1545
Here is the scenario:
I click a button and a popup comes and I want to test when I click on button, the popup should be visible
Sample code:
<button id='bt'>
<div id ='new_div' data-state = visible >
cy.get('#bt').click()
//after clicking this I need to test data-state of "new_div" is visible/not
cy.get('#new_div').should('have.data-state','visible') //something like this
Upvotes: 0
Views: 244
Reputation: 926
You can do this:
cy.get('[data-state = visible]').should('be.exist')
It will basically check if this tag data-state = visible
present or exist inside your DOM at the moment when the popup is visible.
But the best way, of course, is to grab selector from the opened popup!
Upvotes: 1