More than 1 element found when tracking

Best practices, code snippets for common functionality, examples, and guidelines.
poorngocphu
Posts: 4
Joined: Thu Apr 22, 2021 4:03 am

More than 1 element found when tracking

Post by poorngocphu » Tue Apr 27, 2021 5:32 am

Hello everyone.

I test my web application with Ranorex Studio, When i'm tracking the element, but it found more than 1, so Ranorex can't know exactly what elements i want to click, and it click incorrect elements (same type elements i'm tracking). How I can identification unique element i want in the web page have a lot the same elements like this.
I'm codeless, hope you can help me.

Thank you.
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: More than 1 element found when tracking

Post by odklizec » Wed Apr 28, 2021 9:33 am

Hi,

Please create and post a Ranorex snapshot (NOT screenshot) of the app under test. Also, post the xpath (in string form) of the element you are talking about.

Generally speaking, you must enhance the xpath with unique identification attributes, maybe even using another element (typically UI label or text field) as an anchor and from there traverse back to the element in question. Unfortunately, I can't provide a reliable example without seeing the snapshot and xpath in question. Thanks.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

poorngocphu
Posts: 4
Joined: Thu Apr 22, 2021 4:03 am

Re: More than 1 element found when tracking

Post by poorngocphu » Wed Apr 28, 2021 1:29 pm

This is my snapshot, can you help me clearly about enhance the xpath with unique identification attributes.
Thank you.
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: More than 1 element found when tracking

Post by odklizec » Wed Apr 28, 2021 1:32 pm

Hi,

Please post also the xpath (as string), which returns multiple elements. I don't want to retype it from the screenshot you posted ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

poorngocphu
Posts: 4
Joined: Thu Apr 22, 2021 4:03 am

Re: More than 1 element found when tracking

Post by poorngocphu » Fri May 07, 2021 4:15 am

This is my xpath, pls help me. :(
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: More than 1 element found when tracking

Post by odklizec » Fri May 07, 2021 10:26 am

Hi,

I'm afraid, this xpath does not return anything in the snapshot you posted. So please, open the snapshot you posted, manually find the element you want to use and which xpath returns multiple elements. You will have to find the element by expanding and scrolling the element try in Spy.

Generally speaking, the xpath you posted is useless, because there are no unique identifiers and too many element indexes, which are not persistent. Which means that you will have to construct the xpath manually, maybe even using labels associated with the element in question.

For example, let's say you want to type something into Currency input:
SAP_UI.png
Here is the unique xpath, you may need to use:
/dom[@domain='cf-laidon-mdg-test-s4-simple-mdg-web.cfapps.eu10.hana.ondemand.com']//div[#'__bar0-containerContent']//div[@class='sapUiFormCLElement']//label[@class~'sapMLabel']//tag[@innertext='Currency']/ancestor::div[@class='sapUiFormCLElement']//input[@class='sapMInputBaseInner']
As you can see, the xpath first finds the "Currency" label, then returns to nearest common ancestor (common for both label and input) and then from there it goes right to the input ;)
SAP_UI_2.png
Unfortunately, there is no other way than to create such xpath manually.
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration