top of page
Search
Writer's pictureTuyen Nguyen

Retry click until meeting expected conditions

Updated: Dec 27, 2022

Problems:


Waiting for elements to be clickable is always a challenging obstacle to write automated test class. Especially when you want to click on an element that is covered by another layer or not clickable at some periods of time. You may wonder what if we try to click element again and again until somethings happen?

Solutions:


A retry click function which gives you the ability to click element again until an expected condition is met.the

  1. It will check if element is clickable.

  2. If that element is clickable, it will perform click action.

  3. Then, it waits for an expected condition to be successful with timeout is 2 seconds.

  4. After the timeout, if any exception occurs (ex: NotFound,..), it will perform click action again and then wait again.

Example of retryClick() function written in Java:

Pros:

  • Very useful in many cases that element is covered or not clickable at some points of time.

  • Flexible in passed in expected conditions.

  • Easily to modify the timeout of waiting for an element.

1,374 views0 comments
Join my mailing list

Thanks for submitting!

© 2019 by Tuyen Nguyen

© 2019 by Tuyen Nguyen

  • White LinkedIn Icon
  • lm29-5xjdbzxe9s94-mn8yw
  • White Instagram Icon
bottom of page