Selection on Radio button inside dynamic control failing after recording | Licensed user

Ask general questions here.
gsb
Posts: 17
Joined: Wed Mar 17, 2021 3:49 pm

Selection on Radio button inside dynamic control failing after recording | Licensed user

Post by gsb » Tue Apr 13, 2021 7:44 pm

Have recorded the radio button, fails every time rerun the module.
By default Current employee is selected (it worked). But when tried to select Previous Employee it failed
Tried solution
1. Envoke action focus() - Did not work


The path to Previous Employee radio button

.//form[#'formData']/tag[7]/tag/div[2]/div/div/?/?/tag[@tagname='accordion-content']/div/div[2]/?/?/tag[@tagname='row']/div/?/?/tag[@tagname='ng-component']/div/?/?/tag[@tagname='row']/div/tag[1]/?/?/div/?/?/tag[@tagname='row']/div/?/?/tag[@tagname='ng-component']/div[2]/label[@innertext>'Previous Employment']

/dom[@domain='urlname']//form[#'formData']/tag[7]/tag/div[2]/div/div/?/?/tag[@tagname='accordion-content']/div/div[2]/?/?/tag[@tagname='row']/div/?/?/tag[@tagname='ng-component']/div/?/?/tag[@tagname='row']/div/tag[1]/?/?/div/?/?/tag[@tagname='row']/div/?/?/tag[@tagname='ng-component']/div[2]/label[@innertext>'Previous Employment']

This was when selected from inspect element from chrome

<label class="radio-label" id="ex1-radio1-label" for="4a8686c5-c964-090a-6b59-275e42f0b461_1">Previous Employment
<!---->
</label>

Xpath element for previous radio button -> <input checked="" class="mdc-radio__native-control ng-valid ng-touched radio-active ng-dirty" type="radio" id="4e4c21d9-0a31-4a09-1f5c-9f495c3ab71d_1">


Xpath element for Current Radio button radio button
<input checked="" class="mdc-radio__native-control ng-valid ng-touched ng-dirty radio-active" type="radio" id="4e4c21d9-0a31-4a09-1f5c-9f495c3ab71d_0">


JS path
document.querySelector("#\\4e4c21d9-0a31-4a09-1f5c-9f495c3ab71d_1") for Previous
document.querySelector("#\\4e4c21d9-0a31-4a09-1f5c-9f495c3ab71d_1") for Current

/dom[@domain='urlname']//form[#'formData']/tag[7]/tag/div[2]/div/div/?/?/tag[@tagname='accordion-content']/div/div[2]/?/?/tag[@tagname='row']/div/?/?/tag[@tagname='ng-component']/div/?/?/tag[@tagname='row']/div/tag[1]/?/?/div/?/?/tag[@tagname='row']/div/?/?/tag[@tagname='ng-component']/div[2]/label[@innertext>'Previous Employment']

Previous Employment
/dom[@domain='urlname']//form[#'formData']/tag[7]/tag/div[2]/div/div/?/?/tag[@tagname='accordion-content']/div/div[1]//span[@innertext='Previous Employment']
Current Employment:
/dom[@domain='urlname']//form[#'formData']/tag[7]/tag/div[2]/div/div/?/?/tag[@tagname='accordion-content']/div/div[1]//span[@innertext='Current Employment']

Radio button id changed everytime
<div class="mdc-radio">
<input checked="" class="mdc-radio__native-control ng-valid ng-touched ng-dirty radio-active" type="radio" id="4e4c21d9-0a31-4a09-1f5c-9f495c3ab71d_0">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>

<input checked="" class="mdc-radio__native-control ng-valid ng-touched ng-dirty radio-active" type="radio" id="7fa51788-9d42-ff09-c0fe-b334d667ff6a_1">

Error
Failed to find item 'FWDriverRepository.FBPortal.PreviousEmployment'. Please check that your whitelist allows Ranorex to access the process.
No element found for path '/dom[@domain='urlname']//form[#'formData']/tag[7]/tag/div[2]/div/div/?/?/tag[@tagname='accordion-content']/div/div[2]/?/?/tag[@tagname='row']/div/?/?/tag[@tagname='ng-component']/div/?/?/tag[@tagname='row']/div/tag[1]/?/?/div/?/?/tag[@tagname='row']/div/?/?/tag[@tagname='ng-component']/div[2]/label[@innertext>'Previous Employment']' at step 'descendant-or-self::form[#'formData']' after 524 attempts within 1m.
Attachments
radiobutton.JPG
radiobutton.JPG (10.71 KiB) Viewed 203 times

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

Re: Selection on Radio button inside dynamic control failing after recording | Licensed user

Post by odklizec » Tue Apr 13, 2021 9:25 pm

Hi,

At first, the xpaths you are using ,are too complicated and contains too many potentially changing indexes. Recorded/tracked xpaths are not always the best possible xpaths and you should always review them (each and every one of them) and eventually improve them.

At next, could you please upload a Ranorex snapshot (NOT screnshot) for the problematic element(s)? It would be much easier to suggest better xpath with snapshot. Otherwise, it's just a guesswork ;)
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

gsb
Posts: 17
Joined: Wed Mar 17, 2021 3:49 pm

Re: Selection on Radio button inside dynamic control failing after recording | Licensed user

Post by gsb » Wed Apr 14, 2021 4:56 pm

Hi @olklizec

Thanks for reply

Added a snapshot for reference, please let me know the code which one to select and verified and report in logs what got selected.

*attach removed Sorry
Last edited by gsb on Wed Apr 14, 2021 6:25 pm, edited 1 time in total.

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

Re: Selection on Radio button inside dynamic control failing after recording | Licensed user

Post by odklizec » Wed Apr 14, 2021 5:19 pm

Hi,

Thanks for the snapshot. Apparently, the ID attributes for given radio buttons are dynamic and therefore useless ;) Which means, you need to find 'label' of given radio button and from there traverse to the associated radio button, using xpath relationship operators (in this case preceding-sibling). You should also simplify the xpaths, to make them more change-proof and stable. So here are the optimized xpaths, which should work under any circumstance:

/dom[@domain='YourDomain']//form[#'formData']//label[@innertext>'Previous Employment']/ preceding-sibling::div[@class='mdc-radio']/input[@type='radio' and @tagname='input']

/dom[@domain='YourDomain']//form[#'formData']//label[@innertext>'Current Employment']/ preceding-sibling::div[@class='mdc-radio']/input[@type='radio' and @tagname='input']

Hope this helps?
Last edited by odklizec on Wed Apr 14, 2021 10:55 pm, edited 1 time in total.
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

gsb
Posts: 17
Joined: Wed Mar 17, 2021 3:49 pm

Re: Selection on Radio button inside dynamic control failing after recording | Licensed user

Post by gsb » Wed Apr 14, 2021 10:30 pm

Hi I am sorry it did not work out

Humble request to pls edit the domain (@domain-'baseurl.com') in previous reply. Please
odklizec wrote:
Wed Apr 14, 2021 5:19 pm
So here are the optimized xpaths, which should work under any circumstance
Hope this helps?
[/quote]

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

Re: Selection on Radio button inside dynamic control failing after recording | Licensed user

Post by odklizec » Thu Apr 15, 2021 7:10 am

Hi,

What exactly didn't work? Is there an error message? You need to be as much specific as you can, otherwise, it's impossible to provide a reasonable answer.

The xpaths I provided definitely work with the snapshot you posted. If there is different domain used, you need, of course, adapt the domain.

In order to debug this problem, you need to create a Ranorex snapshot directly from recording. Just add Create Snapshot action before the failing action and grab the snapshot of entire app. This should help with analyzing what's wrong and you may eventually adapt the xpath by adding some more elements. Your app under test appears to be quite complicated, so you may need to add few more xpath elements here or there.
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

gsb
Posts: 17
Joined: Wed Mar 17, 2021 3:49 pm

Re: Selection on Radio button inside dynamic control failing after recording | Licensed user

Post by gsb » Fri Apr 23, 2021 5:23 pm

Hi odklizec,

The xpath was updated so changed it and worked out as you said.

Working fine now

Thanks

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

Re: Selection on Radio button inside dynamic control failing after recording | Licensed user

Post by odklizec » Mon Apr 26, 2021 8:53 am

Hi,

Nice to hear that!
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