FluentAutomation
FluentAutomation copied to clipboard
A way to check if element exists/visible (bool)
Am I right there's no way to just ask if there an element?
Both Expect/Assert
and Find
just throws when they can't find the element. It's OK when you want to describe test success condition, but in my case I want the test logic to be different, depending on the state of the page (namely, I want to execute login only if user isn't logged in yet).
My solution to this problem was to create an extension method to IActionSyntaxProvider called Exists that calls Find and catches the exception to determine if it exists. Then it can return true or false to indicate whether the element exists.
@predeekc thanks for the solution. It feels like it's more a workaround, though.