Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does Cypress has analogue to Selenium's WebElement.isDisplayed? #1737

Closed
b-ponomarenko opened this issue May 18, 2018 · 3 comments
Closed

Does Cypress has analogue to Selenium's WebElement.isDisplayed? #1737

b-ponomarenko opened this issue May 18, 2018 · 3 comments

Comments

@b-ponomarenko
Copy link

In many cases we need to check if element displayed (is visible in viewport). Selenium has method isDisplayed method for it. Does Cypress has same method or API?

@chrisbreiding
Copy link
Contributor

You can use .should('be.visible') to test if an element is visible. Note that it doesn't fail if the element is outside the viewport. It's really an assertion for whether the element is visible or could be visible to the user with scrolling. There's some discussion about that here.

@brian-mann
Copy link
Member

In Cypress you have native access to everything. We don't need to create commands for everything because you have the entire power of JavaScript at your disposal.

The question could be rephrased: "in javascript how do you detect if an element is visible?". Whatever that answer is is the same for Cypress.

Internally we use quite a few helper methods we created when determining visibility. They are all attached to Cypress.dom.

You could try looking at that object and I believe the method you're looking for is in there.

@b-ponomarenko
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants