Is there a way to test how many copies of an element exist?

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
QATest879
Posts: 31
Joined: Fri Jul 02, 2021 2:35 pm

Is there a way to test how many copies of an element exist?

Post by QATest879 » Tue Aug 10, 2021 7:25 pm

Hello. I'm wondering is there any simple or fast way to get the number of copies of a single element?

Assume the same exact image with the same RanorexPath appears on the window screen 30 times. Is there any way I could do something like:

Variable = GetElementCount(repo.Element);

Does anything like that exist? That will return the count of copies of a single element on the screen?

Is there anywhere where the instance count is stored? Like, does anything exist that is like, repo.ElementInfo.NumberOfInstances?

Or, there must be some kind of indexing, right? Like, repo.Element[1] and repo.Element[2] if there are multiple copies of the same element on the screen at once? Does anybody know how I can access the different indexes and go through them one at a time to validate them all? I'm looking for general advice on how to get the instance count when the same element appears multiple times on the screen. I'd need to know how many times that particular element appears.

Thank you.

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

Re: Is there a way to test how many copies of an element exist?

Post by odklizec » Tue Aug 10, 2021 8:43 pm

Hi,

Sure, there is a way to count the elements with the same xpath. Please follow the steps from this post:
how-to-get-the-total-size-of-the-webele ... tml#p67339
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

QATest879
Posts: 31
Joined: Fri Jul 02, 2021 2:35 pm

Re: Is there a way to test how many copies of an element exist?

Post by QATest879 » Wed Aug 11, 2021 3:43 pm

Thank you very much that worked. In my particular example I had to use JavaElement instead of SpanTag because my elements were JavaElements, but I changed it and it's working now. Thanks.