Afternoon,
I've searched but cannot find an answer to an issue I'm having with selenium. I need to find a way to ensure elements are not displayed on a page. Basically, our users have varying levels of permissions, which results in different tabs being displayed.
We've had a few issues recently and incorrect tabs have been displayed for users that shouldn't see them. Now asserting an element is present is no issue at all, but this wont ensure rouge tabs are not present. Any help would be appreciated on this one, as it's proving difficult and I'm sure this isn't that complicated.
We're using Selenium WebDriver and writing the tests in C#.
Thanks,
Stu.
Use webdriver's findElements method, if the List of WebElements returns size as 0, you can assert for the count of elements.
To ensure rouge tabs are not present you can use either of the ExpectedConditions clause from the following :
ExpectedConditions.InvisibilityOfElementLocated Method :ExpectedConditions.InvisibilityOfElementLocated can be used for checking that an element is either invisible or not present on the DOM.
Return Value : true if the element is not displayed, otherwise false.
ExpectedConditions.InvisibilityOfElementWithText Method :ExpectedConditions.InvisibilityOfElementWithText can be used for checking that an element with text is either invisible or not present on the DOM.
Return Value : true if the element is not displayed, otherwise false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With