Generic Button Navigation

Ranorex Spy, Recorder, and Studio.
eldorado25
Posts: 22
Joined: Tue Aug 06, 2019 4:14 pm

Generic Button Navigation

Post by eldorado25 » Wed Feb 26, 2020 11:49 am

Hello again,


Our web application has a nav bar and I am trying to create a Generic Button Navigation class, which would allow for a variable to decide which button is pressed from any document (as this nav bar appears in most screens).

I think I know how to do this
To get the button

Code: Select all

public static Ranorex.WebElement getEle(string path, int timeout){
			Element ele = null;
			Host.Local.TryFindSingle(path, timeout, out ele);
			try{WebElement we = new WebElement(ele);return we;}
			catch{
					if(path.Equals("path")) {
						Report.Log(ReportLevel.Info, "Form not found, waiting for form to load.");
					}else{
						Report.Log(ReportLevel.Warn, "Not found: "+path);
					}
			}
And to then finally navigate to the correct button

Code: Select all

getele(path + BUTTONNAME + restOfPath, timeout).Click()
I am just wondering if perhaps this is not best practice or does another solution exist?

eldorado25
Posts: 22
Joined: Tue Aug 06, 2019 4:14 pm

Re: Generic Button Navigation

Post by eldorado25 » Wed Feb 26, 2020 12:00 pm

I think I have realised the issue with using this way,

I would have to end up creating a large number of Variables or parameters to make this work effectively whereas it would make more sense just to have all of the buttons in the Repository anyway, as it would reduce the amount of logic required.