web testing with automation ID

Ranorex Studio, Spy, Recorder, and Driver.
User avatar
jkischel
Posts: 5
Joined: Wed Jun 08, 2022 7:55 am

web testing with automation ID

Post by jkischel » Thu Aug 04, 2022 10:28 am

I'm using Ranorex Studio 9.5.3 and currently working on a web project.

I want to access a web image like this one:

Code: Select all

<img _ngcontent-ugb-c11="" automationid="headerCompanyLogo" src="/assets/images/CompanyLogo.svg" alt="Company logo" class="companyLogo">
Ranorex Spy automatically creates this path:

Code: Select all

?/?/?/?/?/picture[@accessiblename='Company logo']
But as the page is going to be localized, the alt tag is useless as it can change.

Due to the documentation, element properties can be used, so I tried this Xpath:

Code: Select all

?/?/?/?/?/picture[@automationid='headerCompanyLogo']
but that doesn't work. Even though I directly copy & pasted the attribute and value, Ranorex doesn't find the element. But why? The automationid attribute will be a unique identifier that is intended exactly for this.
System information:
I'm using Ranorex v9.6.3 on a Windows 10 machine.

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

Re: web testing with automation ID

Post by odklizec » Wed Aug 31, 2022 7:58 am

Hi,

Unfortunately, it's impossible to tell what's wrong without seeing, at very least, a Ranorex snapshot of the problematic element. Please create and post the snapshot (NOT screenshot) so we can look into it and possibly suggest the best solution. 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

User avatar
jkischel
Posts: 5
Joined: Wed Jun 08, 2022 7:55 am

Re: web testing with automation ID

Post by jkischel » Mon Sep 12, 2022 1:34 pm

This is easily reproducible, even without a ranorex snapshot.

Just create any html document and add this tag in the body
<img _ngcontent-dae-c14="" automationid="headerWagoLogo" src="/assets/images/WagoLogo.svg" alt="WAGO logo" class="wagoLogo">
The problem is solved, but just by half. The problem why the <img> tag was captured as "picture" was because the instrumentation didn't work properly. The browser extension was present, showed the dialog when the icon was clicked, but was somehow not working. However, I fixed this problem in the meantime by completely re-installing all stuff.

Now, let's come to the half that still does not work:
Prerequisite: I have created a rule in the spy options (settings -> advanced -> edit attribute weights) that should give the highest priority to use an automationid if present:
screenshot_ranorexspy.png
Now, I click "track" and select this element. The spy never ever is using this automationid attribute, even not if I create a blank ranorex project and delete all other rules.

Ranorex spy automatically creates this xpath:
/dom[@domain='url-of-testserver-here']/body//tag[@tagname='app-header']/div/div/img[@alt='WAGO logo']

But as I set the weight the highest as possible, shouldn't the Ranorex spy create this xpath (which btw. works perfectly!)?
screenshot_ranorexspy2.png
My question is: why does the Ranorex Spy completely ignore the automationid attribute that even has the highest priority at all?

Btw. I may not add a Ranorex Snapshot as this would disclose content that may not be published.
You do not have the required permissions to view the files attached to this post.
System information:
I'm using Ranorex v9.6.3 on a Windows 10 machine.