Variable in RxPath Not Updating During Test Case Run

Ask general questions here.
rphmee
Posts: 6
Joined: Tue Jun 05, 2018 2:46 pm

Variable in RxPath Not Updating During Test Case Run

Post by rphmee » Wed Aug 08, 2018 8:40 pm

I currently have a test case parameter that I'm using to complete the path of an element in my repository. A section of user code in this test case changes the value of this parameter during the test's execution, however it seems that the path is setting its value to the original parameter value at the start of the test case, and doesn't get the updated value. The parameter is being updated in the user code, which I'm checking with a Report.Info, so that doesn't seem to be the issue.

Is this intended, and is there a way to fix it?

User avatar
Stub
Posts: 173
Joined: Fri Jul 15, 2016 1:35 pm

Re: Variable in RxPath Not Updating During Test Case Run

Post by Stub » Thu Aug 09, 2018 1:54 pm

I'm guessing at what you're doing here, so I think you'll need to provide additional parameters. I use repository variables in my repository paths e.g. [@accessiblevalue=$SomethingOrOrder] and I set Repository.SomethingOrOther as required in my User Code, but I'm unclear if that's what you're referring to.

rphmee
Posts: 6
Joined: Tue Jun 05, 2018 2:46 pm

Re: Variable in RxPath Not Updating During Test Case Run

Post by rphmee » Thu Aug 09, 2018 2:43 pm

That seems to be what I'm trying to do. The path I'm using in my repo is: table/tbody/tr[$machineRow]/td[11]/a[@innertext='Edit']

Then in my user code I set machineRow (which is a test case parameter) to whatever row my user code determines, but it seems that this value isn't being used when I access that repo element later in the test case. It seems to just be using the default value I had prior.

If this is what you're doing and its working I guess I'm just screwing up somewhere, will have to investigate a little more.

User avatar
Stub
Posts: 173
Joined: Fri Jul 15, 2016 1:35 pm

Re: Variable in RxPath Not Updating During Test Case Run

Post by Stub » Thu Aug 09, 2018 3:54 pm

Your mention of "test case parameter" puzzles me. I think you mean the variables on the "Data binding" tab of a Test Case properties dialog? Those aren't the same things as Repository Variables.

It sounds like you're passing parameters into your code module? For example:
        string _ColumnIndex = "3";
        [TestVariable("4376f089-50d0-4179-b06e-1f28adfc13a6")]
        public string ColumnIndex
        {
            get { return _ColumnIndex; }
            set { _ColumnIndex = value; }
        }
However, what I'm talking about is configuring my variable repository items. I do something like this in my user code, where "Properties" is a Properties.rxrep repository in my Ranorex solution:
            Properties.Column = ColumnIndex;
            Validate.Attribute(Properties.Dialog.Grid.Header.NthColumnInfo, "AccessibleName", ExpectedName, Constants.ValidateAttributeMessage, true);
Where my repository item will have "cell[$Column]" in it. This reads the value I have assigned to Properties.Column in the above code.

rphmee
Posts: 6
Joined: Tue Jun 05, 2018 2:46 pm

Re: Variable in RxPath Not Updating During Test Case Run

Post by rphmee » Thu Aug 09, 2018 8:12 pm

What I was referring to with "test case parameter" was the Parameter table you can reach by right clicking on a test case and going to data binding.

What I was trying to do was change the value of one of these parameters from within the test case itself, which wasn't possible. I ended up switching a line that read something like:

TestSuite.CurrentTestContainer.Parameter["parametername"] = newValue;

to

repo.varName = newValue;

And now its working. Thanks for the help!

User avatar
Stub
Posts: 173
Joined: Fri Jul 15, 2016 1:35 pm

Re: Variable in RxPath Not Updating During Test Case Run

Post by Stub » Fri Aug 10, 2018 8:37 am

Huzzah!

I didn't know you could do things like:
TestSuite.CurrentTestContainer.Parameter["parametername"] = newValue;
I tend to pass updated parameters out via the code module parameters. Another new Ranorex trick for my arsenal.