How to store the element ID in variable and used in XPath?

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
NavinS
Posts: 9
Joined: Wed Nov 21, 2012 3:52 pm

How to store the element ID in variable and used in XPath?

Post by NavinS » Wed Nov 21, 2012 4:00 pm

Hello,

Is there anybody let me know how to store the element id from XPath and used in another XPath?
My Scenario is:
I'm creating a component and the component generating the unique component id, other value like class are same for all other components but div id is different. After create the component I want to click on that created component. The issue is, component name could be same.
Please let me know how can I click on same created component?
Can I store the component ID in some variable from XPath and use that variable in another XPath while I want to click over that?

Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: How to store the element ID in variable and used in XPath?

Post by Support Team » Thu Nov 22, 2012 2:36 pm

Hello,

In order to store the ID in a variable you could use the code below. Please make sure that you use the correct Ranorex.Adapter. You would need to create a repository variable (elementID) at first.
Ranorex.InputTag element;
Host.Local.TryFindSingle("/dom[@domain='www.ranorex.com' and @caption='Ranorex Test Page']//input[@id='testname']", out element);
repo.elementID = element.Id;
After that you could use the method 'TryFindSingle' to get the element and perform a Click() action on it.

Regards,
Markus (T)