Click item from UserCode with Variable in RxPath

Ask general questions here.
mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

Click item from UserCode with Variable in RxPath

Post by mrt » Fri Mar 31, 2023 1:25 pm

Dear folks,

following scenario:

I need to conditionally execute a Click() event on a repository item, where the repo item has a variable in its RxPath.
This works without issues when using a separate smart folder with a condition on it.
Downside is, when copying the whole folder between different data sources the condition always loses its reference and needs to be reset, which is cumbersome and error-prone (I am not the only one doing this and there are some smart folders of same implementation).

So my decision is to put the condition in UserCode, where it does not lose any reference, but I can't get it to work because the variable stays always empty in repository.

RxPath of repo item:

Code: Select all

tag[#$id]
User Code Module:

Code: Select all

if (!string.IsNullOrEmpty(attributeTab))
{
    myRepo.tab_ById.Click();
}
But when executing this, the $id is always empty (therefore the element is not found).
I tried to add the $id variable also to the UserCode Module, and I see its value there correctly, but the RxPath of the repo item still does not know about it.

Any ideas?

thanks!

IvanF
Posts: 151
Joined: Thu Aug 11, 2022 8:55 pm

Re: Click item from UserCode with Variable in RxPath

Post by IvanF » Mon Apr 03, 2023 2:15 pm

Hi, you may want to double check how the variable "id" is defined in the user code, there should be a section like this
UserCodeVariables.jpg
You may then need to edit that section to make the variable more suitable for the user code approach, as discussed here - https://www.ranorex.com/help/latest/ran ... n-testing/
You do not have the required permissions to view the files attached to this post.