Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get one that is not hidden tag?

I have three similar div tags as shown below:

<div data-test="someId" style="position: fixed; visibility: hidden;">more tags</div>
<div data-test="someId" style="position: fixed; visibility: hidden;">more tags</div>
<div data-test="someId" style="position: fixed;">more tags</div>

Note: here data-test id is same for all three.

All I want is the tag that is not hidden i.e third one

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’ve tried cy.get('[data-test=someId]').should('not.have.css', 'visibility') but it’s not working.

>Solution :

You can use the :visible jQuery selector. Beware of which route you go with cypress retryability.

// get only visible element(s)
cy.get('.element:visible')
  // retry cy.get('.element:visible')
  .should('be.visible')

// get element(s)
cy.get('.element')
  // filter only visible element(s)
  .filter(':visible')
  // retry .filter(':visible')
  .should('be.visible')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading