Manipulation RxPath in Repo goes wrong

Best practices, code snippets for common functionality, examples, and guidelines.
Andi
Posts: 5
Joined: Thu Oct 25, 2018 12:33 pm

Manipulation RxPath in Repo goes wrong

Post by Andi » Sun Jan 27, 2019 9:57 pm

Hello erveryone,

Im new in Ranorex and have problems to manipulate RxPath in Repo.

I have Table with two colums in the first are Ids in the second toggle buttons for each Id to change status.
I have to find right id in the table and change status of this Id with button.
It works fine if there is no variable in RxPath: Ranorex is chooses always the right row there requied Id is and clicks the button in the nex column of this row.

This how the RxPath looks in this case ( its innertext of span):

Code: Select all

dom[...//span[@innertext='1234']/../../..//div[2]/tag[2]//span[@class='mat-slide-toggle-content']
But Ihave to make innertext varible and do it this way:

Code: Select all

dom[...//span[@innertext=$value]/../../..//div[2]/tag[2]//span[@class='mat-slide-toggle-content']
here is my user code:

Code: Select all

string value = "5678";
repo.Portal_Hauptmaske.MedienUndFahrer.Ladekarten.LadekartePruefung.LabelAktivDeactiv.TagValue = value;
repo.Portal_Hauptmaske.MedienUndFahrer.Ladekarten.LadekartePruefung.LabelAktivDeactiv.Click();
And the tescase execution selects allways the fist object in the table.

Anybody idea what I do wrong?

DavidH
Posts: 6
Joined: Mon Jan 22, 2018 2:49 pm

Re: Manipulation RxPath in Repo goes wrong

Post by DavidH » Mon Jan 28, 2019 8:27 am

Why do you use .TagValue?

So your repo item has the following xpath. Including the variable "$value"

Code: Select all

dom[...//span[@innertext=$value]/../../..//div[2]/tag[2]//span[@class='mat-slide-toggle-content']
Then you should update the value of $value like this:

Code: Select all

repoName.value="5678"; 

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

Re: Manipulation RxPath in Repo goes wrong

Post by odklizec » Mon Jan 28, 2019 8:49 am

Hi,

At first, please upload a Ranorex snapshot of the problematic element. Without snapshot, it's very hard to suggest something reliable. At next, the xpath you are using, is potentially fragile and may easily break (after simple AUT change). So I would suggest to simplify it a bit. But again, without snapshot (NOT screenshot), it's impossible to suggest something sensible ;)
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

Andi
Posts: 5
Joined: Thu Oct 25, 2018 12:33 pm

Re: Manipulation RxPath in Repo goes wrong

Post by Andi » Mon Jan 28, 2019 2:40 pm

Thanks for Help,

Code: Select all

repoName.value="5678"; 
works fine :D