Using QF-Test as Calculator

Sometimes it is necessary to perform mathematical calculations in QF-Test, e.g. in order to calculate the expected height of a GUI element in dependence of the complete window size or the exact clicking position for a mouse click.

In order to do so we can use a Scripting node. Alternatively it is possible to use the $[some mathematical expression] expression within node attributes. Like this the expression $[3 + 3] will be replaced by 6. When we have stored the width of a current element in a QF-Test variable named “canvasWidth”, we can use $[$(canvasWidth) – 1] in order to click somewhere at the right border of a GUI element:

Basic math in nodes QF-Test

In fact the mathematical expression in the brackets is passed to a Jython eval statement. So it is also possible to perform more sophisticated operations within such an “$[…]” expression:

  • $["Hello World"[1:5]] will be replaced by “ello”.
  • $[rc.getLanguageName()] will be replaced by “jython”.
  • $[re.split("\\d*", "foo123bar4foobar")[1]] will be replaced by “bar”. Please note, this statement will only work if you have previously executed a Jython Server Script that imports the re-module.
  • $[__import__('re').split("\\d*", "foo123bar4foobar")[1]] will be replaced by “bar” (this statement will work whether a Jython Server Script that imports the re-module has been executed or not).

We use "Matomo" cookies to anonymously evaluate your visit to our website. For this we need your consent, which is valid for twelve months.

Cookie Configuration

Functional cookies

We use functional cookies to ensure the basic functionality of the website.

Performance and statistics cookies

We use Matomo for analyzing and optimizing our website. Cookies permit an anonymous collection of information that help us offering you a clear and user-friendly visit of our web pages.

Cookie details
Description Vendor Lifetime Type Purpose
_pk_id Matomo 13 Months HTTP Contains a unique, pseudonymized visitor ID internal to Matomo for recognizing returning visitors.
_pk_ref Matomo 6 Months HTTP Used to track from which website the anonymized user proceeded to our website.
_pk_ses Matomo 1 Day HTTP The Matomo session cookie is used to track the visitor's page requests during the session.
_pk_testcookie Matomo Session HTTP Used to check whether the visitor's browser supports cookies.
_pk_cvar Matomo 30 Minutes HTTP Temporarily store data about the visit.
_pk_hsr Matomo 30 Minutes HTTP Temporarily store data about the visit.