How to make test react faster to a missing object?


#1

Hello!
I have a button in a webpage which is not always there. I want to click it if it’s there. If the button is absent, I want to keep the test running.

I tried using VerifyElementIsVisible and such but they wait a while before continuing.
Currently I use FailureHandling.Optional on Click action but I would like to know a better method to do it, preferable one that doesn’t wait before executing rest of the code.

Thanks!


#2

This is a strategy question (and solution).

  1. Build a list of always-present elements.
  2. Wait for page load etc.
  3. Test for visibility of always-present elements. Test ALL of them.
  4. Optional: add a short delay (1 or 2 seconds)
  5. Proceed with test.

Now you can add a short timeout for your sometimes-present element(s).


#3

But testing visibility on one object takes time, specially if he’s not there. Correct me if I’m wrong, but there’s no timeout on Check for visibility. I would like to have a 1 sec timeout or so.


#4

Yeah, the docs are broken. I’ve reported it umpteen times. Keep this link handy:

And notice the URL - you can change “visible” to “present”, etc.


#5

Ok, I guess i’ll use Wait for Element Visible with a really short timeout because VerifyElementIsVisible doesn’t have timeout. It’s just a bit counter intuitive.


#6

Not sure what you mean - Wait* is "Verify+Timeout". In my view, prefer Wait over everything.


#7

Basically Verify documentation is wrong, also I don’t see much use for it.
I just modified my test with Wait function and it does work.