Page 1 of 1

How to make Ranorex touch button until another element exist

Posted: Mon Oct 09, 2017 8:49 am
by MartinKubal
Hi,
I need to set if else condition to find BTN_Controller on the screen. If it is not on the screen, user should touch the BTN_SearchNetwork to make another searching and than again check the page if there is our Controller. Maybe you would have to do it few times, until you find the right Controller (because Controller checks with network in intervals and it is possible that for half a minute it wouldn't be visible for search utility).

I have this code, but it's not working, in fact it's not doing anything.

Code: Select all

public void FindController()
        {
        	var bTN_SearchNetwork = repo.WMA_WiserSmartAndroid.Index.InstallerLoginSteps.ChooseController.BTN_SearchNetwork;
        	var bTN_ControllerInfo = repo.WMA_WiserSmartAndroid.Index.InstallerLoginSteps.ChooseController.BTN_ControllerInfo;
        	var bTN_Controller = repo.WMA_WiserSmartAndroid.Index.InstallerLoginSteps.ChooseController.BTN_Controller;
        	if (bTN_ControllerInfo.Exists() == true)
        		bTN_Controller.EnsureVisible();
        	else bTN_SearchNetwork.Touch();
        }
Can you help me with this please? I am not programmer and I am learning C# only for Ranorex.

Re: How to make Ranorex touch button until another element exist

Posted: Mon Oct 09, 2017 11:13 am
by MartinKubal
And there is working solution....

Code: Select all

public void FindController(RepoItemInfo BTN_Controller)
        {
        	int counter = 0;
          	do
          	{
        	if (BTN_Controller.Exists() == true)
        		repo.WMA_WiserSmartAndroid.Index.InstallerLoginSteps.ChooseController.BTN_Controller.EnsureVisible();
        	
        	else repo.WMA_WiserSmartAndroid.Index.InstallerLoginSteps.ChooseController.BTN_SearchNetwork.Touch();
        	counter = counter +1;
			} while(counter < 10); 
          	        	
        }