Override scalar variables defined in Variables section

Hello Roboteers,

I am looking for a solution for using scalars in Windows application automation (I guess that web automation might have similar requirement). I and using FlaUI library, and all the identifiers are declared in the Variables section or in resource file.

The way the identifiers are defined is top-down, according to the graphic elements hierarchy, a simple example, for the application’s login window:

*** Variables ***
${WINDOW_TITLE} Main Window version -
${LOGIN_USER_TEXT_FIELD} ${LOGIN_WINDOW_NAME}/Edit[@AutomationId=‘Username’]
${LOGIN_PASSWD_TEXT_FIELD} ${LOGIN_WINDOW_NAME}/Edit[@AutomationId=‘Password’]
${LOGIN_BUTTON} ${LOGIN_WINDOW}/Button[@Name=‘Login’]

So each scalar contains previously declared scalar, mostly the parent graphic element. Since we started to release new versions of the application, the Window’s title is now contains a version text. I wish that the same automation will test all the versions, so I am looking for a solution to modify all variables content.

Obviously, changing the top variable during the test has no affect on the rest of the variables, in the above example the value of ${LOGIN_USER_TEXT_FIELD} is /Window[@Name=‘Main Window version -’]/Edit[@AutomationId=‘Username’]
And modify ${WINDOW_TITLE} to Main Window version - V2 has no affect on ${LOGIN_USER_TEXT_FIELD}.

We have a lot of tests for this application and before going for this major change adventure I wish to receive some advice. RF 5.1 Python 3.8.2

Thanks !

Hi @Guto,

A simple solution might be something like this:

*** Variables ***
${WINDOW_TITLE}    Main Window version - ${APP_VERSION}

When you run the robot command for the next version add -v APP_VERSION:V3 etc. and if you are using CI/CD get the build system to pass the version number for you.

Another option, because FLAUI uses a XPath locator you might be able to use wildcards (Selecting Unknown Nodes) or XPATH Functions (e.g. contains or starts-with), e.g.

*** Variables ***
${WINDOW_TITLE} Main Window version - *


*** Variables ***
${WINDOW_TITLE} Main Window version - 
${LOGIN_WINDOW_NAME} /Window[contains(@Name,‘${WINDOW_TITLE}’)]


*** Variables ***
${WINDOW_TITLE} Main Window version - 
${LOGIN_WINDOW_NAME} /Window[starts-with(@Name,‘${WINDOW_TITLE}’)]

Hopefully one of these gives you the solution you need,


Thanks Dave, I did try all these methods, and although they worked on other elements, they failed on Window. But I did gave me an idea and I found out that all versions are using the same Automation ID, so I just replaced the Name with Automation ID and it works. Thanks !

1 Like