Page 1 of 1

How to get, update and use a repo items Xpath in user code

Posted: Wed Jun 11, 2014 3:21 pm
by houseofcutler
Hi There,

I wanted to use an existing repository item path but then add to it to find a related element from which I could output a value (this will actually be used in validation later.

This is what I came up with and it works - It took me a little while to work it out (I'm still new). In the interest of improving my coding I am just wondering if there is a better/more efficient way than this
public void Get_Badge_Value()
        {
        	RxPath path = repo.ComGroupcallEmerge.ViewAnimator.Scroller.android_widget_LinearLayout.LinearLayout1.StudentDetails.Timetable.GetPath();
       	
            path = path +"/../../text[@rid='badge']";
        
            Text badge = Host.Local.FindSingle<Ranorex.Text>(path);
            
            string badgeNumber = badge.Element.GetAttributeValueText("Caption", new Regex("^([^a-zA-Z]*)"));
            Report.Info("User",badgeNumber);
 
        }
Many thanks

Ben

Re: How to get, update and use a repo items Xpath in user code

Posted: Fri Jun 13, 2014 11:38 am
by Support Team
Hi Ben,

You could for instance also use the following approach to get the text element:
Ranorex.Text badge = repo.ComGroupcallEmerge.ViewAnimator.Scroller.android_widget_LinearLayout.LinearLayout1.StudentDetails.Timetable.FindSingle<Ranorex.Text>("./../../text[@rid='badge']");
//...
Regards,
Markus

Re: How to get, update and use a repo items Xpath in user code

Posted: Thu Jun 19, 2014 3:04 pm
by houseofcutler
Hi Markus,

That way is much better - thanks