Reputation: 97
An existing application has an html table, within the body tag, there are multiple td tags with the same name
Ranorex isn't able to all of them to the repository, since all of them have the same XPath.
How can I add these items to the repository?
I tried making a recording, the repository that was automatically created contained only one repository item..
NOTE: I cannot make any changes to the application
Upvotes: 2
Views: 6759
Reputation: 57
This would be a lot easier with more information, like what is the Ranorex XPath that you're given when you add any of the items to the repository?
Also, outside of the way Max mentioned above whereby you add the ENTIRE table to the repository and then find descendants NOTE: Not children, as children only finds elements from the next set down, so may not find what you're looking for all the time (which would look something like this):
foreach(Ranorex.TdTag tags in repo.testWebsite.tdTable.FindDescendants<Ranorex.TdTag>())
{
if(tags.TagValue.contains("<tagname>"));
{
tags.<DOSOMETHING>();
}
}
Note that this should go through all tags and do the same thing for them.
Outside of this, although all the tags probably get found and shown the same way in the repository, there are multiple of them, so it may be possible to shove it in a Rooted Folder, adding the ENTIRE table as the root, and then adding the td tags as arrayed items.
.//div[#'pagecontent']/div[1]/div[2]/div/div/ul/form[2]/li/input[@name='Submit']
The above example has multiple /div sections, so to determine which one to search for you put in the [#], div[1] or div[2], as these are the 1st or 2nd /div tags you come across. The tdTags might work the same way in that you can tag tdtag[1],[2],[3], etc. but it may be worth a shot, as it would then allow you to create the repository items you're after.
Quite new to this myself, so may be wrong about assumptions.
EDIT Wait, did Max answer his own question? Haha...
Upvotes: 1
Reputation: 737
The easiest way i have found is to add a single item to the repository that represents all the items. IE. "./Select/option" will recognize all elements in a options list box, then in user code use the repoiteminfo.createAdapters (http://www.ranorex.com/Documentation/Ranorex/html/M_Ranorex_Core_Repository_RepoItemInfo_CreateAdapters__1.htm) method to create individual adapters for each element
Upvotes: 0
Reputation: 97
Here's how : Find the parent element, and use find children in the code
This doesn't allow you to actually add the items in a repository , but at least you can get a list of items and access them individually by iterating through the list!
Upvotes: 0
Reputation: 1
You have to create a custom UI Automation provider which will expose these elements. Look at the System.Windows.Automation.Provider namespace for details.
Upvotes: 0