Repo item get's destroyed in user code after relocation in repo tree

Ranorex Studio, Spy, Recorder, and Driver.
julez90
Posts: 13
Joined: Thu Apr 25, 2019 2:32 am

Repo item get's destroyed in user code after relocation in repo tree

Post by julez90 » Mon Feb 21, 2022 11:49 pm

Hello,

is it the normal behavior that repo items used and referenced in user code modules get "crushed" as soon as i'm changing the the place where it is located within the object repository?

For example when i'm moving the repo item to another simple folder on another tree level in the repo hierarchy it gets partly "destroyed" and i have to fix it manually.

See the attachment for an example.


Kindly Regards and thanks in advance
julez
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: Repo item get's destroyed in user code after relocation in repo tree

Post by odklizec » Tue Feb 22, 2022 8:10 am

Hi,

Yes, that's quite normal behavior. Ranorex does not automatically update such referenced repo elements in code. This is why you should not use them directly in code, but instead to pass them to methods via repoiteminfo or adapter parameter, like this (just an example):

Code: Select all

public static void SearchAnElement(RepoItemInfo repoElement)
{
    if (repoElement.Exists(10000))
    {
        var foundElement = repoElement.CreateAdapter<Ranorex.Unknown>(false).FindSingle("//*[@automationid='idstring'");
        ...
    }    
}
Where repoElement should be connected with repo item of your choice. Ideally, use RepoItemInfo, but of course, you can use directly Adapter, so there is no need to convert RepoItemInfo to Adapter in code. However, it's safer to use RepoItemInfo, because if the element does not (yet) exists at a time the test enters the method (with Adapter as a parameter), it may fail due to 'element not found' exception. This does not happen in case of RepoItemInfo! So even though it's faster to use Adapter, it's safer to RepoItemInfo ;)
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

julez90
Posts: 13
Joined: Thu Apr 25, 2019 2:32 am

Re: Repo item get's destroyed in user code after relocation in repo tree

Post by julez90 » Tue Feb 22, 2022 3:34 pm

Hey odkilzec,

thank you very much for your helpful reponse.

I will take a look on that :-)


KG
julez

odemin
Posts: 11
Joined: Tue Jun 07, 2022 12:01 pm

Re: Repo item get's destroyed in user code after relocation in repo tree

Post by odemin » Wed Aug 31, 2022 8:41 am

odklizec wrote:
Tue Feb 22, 2022 8:10 am
Ranorex does not automatically update such referenced repo elements in code.
I think this is a bug, if the length of the new path is not changed, then the code will work. As you can see in the screenshot, Ranorex has updated the path, but there is an error in the update.

Also you can check it:
from "repo.folder1.element1" manual move to "repo.abcd123.element1"
it will work fine after moving, all "repo.folder1.element1" in user code was update to "repo.abcd123.element1"

But if new path after move element1 will be "repo.abcd1234.element1", user code will have bug.
I have same problem in https://www.ranorex.info/repository-pat ... 2c871b2678

Also, all path in Action automatically updated, can checked with "view code" after move element.