Utiliser QF-Test comme calculateur

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).

Nous utilisons des cookies "Matomo" pour l'évaluation anonyme de votre visite à note page web. Pour cela nous avons besoin de votre consentement qui est valable pour douze mois.

Configuration de cookies

Cookies fonctionnels

Nous utilisons des cookies fonctionnels pour garantir la fonctionnalité de base du site web.

Cookies de performance et de statistique

Nous utilisons Matomo pour analyser et améliorer notre site web. Des cookies permettent une collection anonyme des informations qui nous aident à vous offrir un visite clair et facile à utiliser de nos pages web.

Détails des cookies
Description Fournisseur Durée de vie Type But
_pk_id Matomo 13 Mois HTTP Contient un identifiant de visiteur unique et pseudonymisé interne à Matomo pour reconnaître les visiteurs qui reviennent.
_pk_ref Matomo 6 Mois HTTP Utilisé pour suivre à partir de quel site Web l'utilisateur anonymisé est arrivé sur notre site Web.
_pk_ses Matomo 1 Jour HTTP Le cookie de session Matomo est utilisé pour suivre les demandes de page du visiteur pendant la session.
_pk_testcookie Matomo Session HTTP Utilisé pour vérifier si le navigateur du visiteur prend en charge les cookies.
_pk_cvar Matomo 30 Minutes HTTP Stocker temporairement les données relatives à la visite.
_pk_hsr Matomo 30 Minutes HTTP Stocker temporairement les données relatives à la visite.