how to loop until a click is successful

Class library usage, coding and language questions.
Posts: 1
Joined: Thu Oct 10, 2019 6:51 am

how to loop until a click is successful

Post by danielm » Thu Oct 10, 2019 7:05 am


I am struggling with a problem with my web-application, where a page is actually loaded but some async calls is blocking the UI randomly for a unpredictable amount of time. I now try to loop in this situation and want to click on a button until it gets available, but the it seems the way i check if the click was successful does not work and so the loops just loops until the end.

Here is the loop section in the c# script.
var index = 10
while (index > 0) {
    result ='Object Repository/Page_X/button_Neue Rufnummer'), FailureHandling.CONTINUE_ON_FAILURE)
    if (result) {
        index = 0
    } else {
        index = (index - 1)
The idea is to check if the click was successful (result == true), set index to 0 and expect the loop to finish. but it keeps stepping trough 10..9..8.. until 0. At an average the successful click happens around the 3rd/4th iteration of the loop.

Using Ranorex 9.1 and rather new to using it.

any help appreciated.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11987
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to loop until a click is successful

Post by Support Team » Fri Oct 11, 2019 10:52 am

Hello danielm,

Unfortunately, it is almost impossible to tell why your loop is not working without seeing the behavior of your application. I'm wondering if there is a better solution than implementing a loop.

May I ask if using a simple "WaitForExists" call would do the trick.

For example: