How to make Ranorex touch button until another element exist

Best practices, code snippets for common functionality, examples, and guidelines.
MartinKubal
Posts: 10
Joined: Wed Aug 16, 2017 8:16 pm

How to make Ranorex touch button until another element exist

Post by MartinKubal » Mon Oct 09, 2017 8:49 am

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.

MartinKubal
Posts: 10
Joined: Wed Aug 16, 2017 8:16 pm

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

Post by MartinKubal » Mon Oct 09, 2017 11:13 am

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); 
          	        	
        }