Page 1 of 1

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

Posted: Wed Nov 21, 2012 4:00 pm
by NavinS
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

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

Posted: Thu Nov 22, 2012 2:36 pm
by Support Team
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)