Hi all!
I have a web-page consisting of multiple elements div[#'blogEntry']. They don't have unique ID's but I need to choose the first and the last elements.
I was able to create a Rxpath to choose the first one (its RxPath is shown on png attached). Though it's exactly the same as the last element's path. When I track the last element with Spy, it finds the path but if I click Enter on this path, then right-click on identified element and choose Highlight element, Spy shows the first one again.
I can see that ChildIndex and ScreenLocation (second argument) change from entry to entry (and for the last blogEntry their values are 62 and 3516 respectively but these numbers will change for another page,they can't be hardcoded) but they're disabled and I can't operate any of those attributes.
Maybe, some regular expressions? functions like last()? I couldn't find anything useful in http://www.ranorex.com/support/user-gui ... xpath.html though this page helps a lot in other cases.
Please, help me to create unique paths for both cases.
Thanks,
Alena.
Identify element without ID
Identify element without ID
You do not have the required permissions to view the files attached to this post.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Identify element without ID
Hello,
Have you already tried the following path to get the last div tag?
Regards,
Markus (T)
Have you already tried the following path to get the last div tag?
Code: Select all
/dom[@domain='yourDomain']//div[#'blogEntry'][-1]
Markus (T)
Re: Identify element without ID
I tried this method as well but it takes enormous amount of time to find an element, so I hoped maybe something faster and easier is available which I don't know about.
In another part of my project, usually up to 6-8 validation points are checked per second, while here it takes up to 15-17 seconds for this single element to find, I guess, because there can be 40-50 [blogEntry] divs on a page.
And you have a mistake in that line of code. It should be either [@id='blogEntry'] or [#'blogEntry'] but not both @#
Thanks anyway Markus!
Alena.
In another part of my project, usually up to 6-8 validation points are checked per second, while here it takes up to 15-17 seconds for this single element to find, I guess, because there can be 40-50 [blogEntry] divs on a page.
And you have a mistake in that line of code. It should be either [@id='blogEntry'] or [#'blogEntry'] but not both @#

Thanks anyway Markus!
Alena.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Identify element without ID
Hello Alena,
In general, searching for an element by a unique ID is quite fast.
Unfortunately, it seems that in your application the same ID is used for several elements (not unique).
This would outweighs the performance benefit for unique IDs.
You could try to extend the RxPath by adding the containers and elements in between.
Instead of the shortened path, you could try to extend it similar to the following path:
Regards,
Markus (T)
In general, searching for an element by a unique ID is quite fast.
Unfortunately, it seems that in your application the same ID is used for several elements (not unique).
This would outweighs the performance benefit for unique IDs.
You could try to extend the RxPath by adding the containers and elements in between.
Instead of the shortened path, you could try to extend it similar to the following path:
Code: Select all
/dom[@domain='yourDomain']/body/div[#'page']/div/div[#'content']/div[@id='blogEntry'][-1]
Markus (T)