Action Window IF and Variables

Ask general questions here.
Posts: 5
Joined: Thu Nov 05, 2020 11:23 pm

Action Window IF and Variables

Post by Dhundley » Fri Nov 13, 2020 5:19 pm

I'm using Ranorex:
Version: 9.3.3+git.bc905490
.Net Runtime: 4.0.30319.42000

At my previous company they had a different automation tool and I'm trying to figure out if certain tasks that I was able do with it are possible in Ranorex.

First, can there be IF statements/conditions inserted into the Action Window (as illustrated by the attached image). sometimes when the OK button (on line 2 of the image) is clicked the processing for that recording is done but at other times a dialog box with a Yes button will appear and needs to be clicked. Is there a way to add an IF condition in the Action Window area (not a code module) between lines 2 and 3 so that the line 3 is only performed if the Yes button is displayed on the screen?

Second, can I create variables for use within my test cases that have nothing to do with input data or external files/data sources and have scope between recordings within the same test case? For instance, let's say I want to define a boolean variable called WindowOpen which is initially set to False. In Recording3 of my test I click on a button that opens a certain window and I want to set WindowOpen to True. In Recording5 something could happen that either closes the window (which would set it's value back to false) or leaves it open. Later, in Recording7, I want to check the value of the WindowOpen variable. If it's true I do one thing. If it's false I do something else. This last check echoes what I mentioned in the previous paragraph about having IF statements in action windows.

Can these be accomplished using Ranorex?

You do not have the required permissions to view the files attached to this post.

User avatar
Ranorex Guru
Ranorex Guru
Posts: 6360
Joined: Mon Aug 13, 2012 8:54 am
Location: Zilina, Slovakia

Re: Action Window IF and Variables

Post by odklizec » Mon Nov 16, 2020 7:17 am


I'm afraid, conditions inside recording table are not yet supported by Ranorex. This feature has been planned, and as far as I remember, it was already in work. But it was not announced yet, so I guess we will have to wait a little bit longer (Ranorex 10 perhaps)? ;)

In a meantime, the only workaround is to convert the affected Recording actions to user code and do the conditional operations in user code. Just select the action or actions you want to make conditional, right click anywhere in selection and select "Convert to user code" (this will convert selection of actions into individual methods) or "Merge items to user code" (this will create one user code method, with all selected actions. After that, you can go to created user code method(s) and add your conditions or other adjustments in code.

As for your second question, sharing variables between recordings, I would suggest you to follow this blog post: ... o-another/
Basically, you should create a parameter in test case/smart folder of your choice, to which you connect the variable form module "A" and then connect this parameter with all modules, where you want to use the variable from module "A". Hope this helps?
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