• 0

How to retry failed test case in any automation framework?

While writing functional automation test cases, one often want to retry things programatically. It could be finding an element on the application, failed test case etc. The below solution shows how to retry finding an element on the application UI. But the logic can be applied to any automation framework with other scenarios as well.

function FindElementWithRetry (app, id, retries) { var element, retries = retries || 3; for (var i = 0; i < retries; i++) { element = app.getElementById(itemId); if (element) { return element; } } };