Category: Documentation
Videotutorial 06: Automating with OCR (Optical Character Recognition)
Maximum Runtime – Error: maxRuntimeMinutes reached
You will see this error when your test runs longer than 1h.
You can change this default to a custom value per test case.
If you want to change the maximum runtime per recording to 2h, set
maxRuntimeMinutes = 120
Cheat Sheet
[Test Setting Page] [Keys] [Branch] [EVAL] [Jumps] [Loops] [max.Runtime] [Sub-Return] [Various Images]
Advanced Commands Test Setting Page
Quality2Threshold | number (try between 30 and 40) |
ExperimentalContinuationLimit | number |
isPersistent | “true“ |
ScreenshottingMode | “device-screen” (high resolution screenshot (‘experimental’ style)) “browser-window” (old ‘non experimental’ style) |
Keys
CTRL + → | rotate clockwise |
CTRL + ← | rotate counter clockwise |
CTRL + R | refresh |
Branch
a,b,c!d,e,f | (a | b | c) & !d & !e & !f (a | b | c) & !(d | e| f) |
en,de,es | en,es Natalie: Action wird ausgeführt in Branches en und es. Jenny: Action wird ausgeführt wenn der Branch en ist, oder es ist. |
Frage: Soll diese Action im aktuellen Branch ausgeführt werden? Antwort: Wenn branch en oder es ist Code: ($BRANCH==”en”) || ($BRANCH == “es”) |
EVAL Statements
Annotation
& && | and (stops after the first argument is true) and (checks both arguments) |
|| | or |
Sendkeys
EVALsendkeys("any text",100)
Parse German Number Format
EVALstr_replace(",", ".", str_replace(".","", $CLIPBOARD))
Checks with Custom Error Messages
FINDimage
EVAL$FLAG || error('specific failure description')
Jumps
Normal Jump
JUMP(T/F)any name
… some more actions …
TAG#any name
Jump based on clipboard value
JUMPscr($CLIPBOARD)
Loops
Simple Loop
TAG#any name
… some more actions …
JUMP (T/F)any name
Maximum Loop Passes
(Option 1 – longer but better readable)
TAG#start
EVALset("counter", get("counter")+1) < 10
JUMP (F)#out
FINDsomething
JUMP (T)#start
TAG#out
Maximum Loop Passes
(Option 2 - shorter with && operation)
TAG#start
... clicking or something ...
FINDsomething
EVALset("counter", get("counter")+1) < 3 && $FLAG
JUMP (T)#start
Limit the Time that a Loop Runs
EVALtime() - set("time", get("time") || time()) < 10 && ....
Maximum Runtime for Blocks
EVALset("time", time())
TAG#start
... some actions ...
EVALtime() - get("time") > 100 && error("More than 100 seconds passed. Stopping")
JUMP#start
Sub - Return
With JUMP sub:test you set the base of the following jump session
The command makes you jump to the TAG #sub:test
With the Jump #return:test you jump back to the place where you started (set the baseline)
JUMPsub:any name
... some more actions ...
TAG#sub:any name
... some more actions ...
JUMPreturn:any name
Combined Image Search
You have different images that show up randomly. That's how you can check if one of them is appearing.
FINDimage1
EVALset("result", $FLAG)
FINDimage2
EVALset("result, $FLAG || $result)
FINDimage3
EVALset("result, $FLAG && $result)
How to use OCR
In case it’s not possible to select or copy a text, use button in mode. Optical Character Recognition will extract all characters that are selected and copy them into a Clipboard content.
Make sure the Editor is in mode.
- Select a stable anchor area.
- Draw a swipe over coded or changing content. Editor automatically switches to mode.
- Click on to change swipe action into OCR action. The recognized area, marked in green rectangular, is copied to Clipboard content.
- Click Play it to confirm and record the action.
PHP: Make test fail
In order to make a test fail due to changes in data, click Editor->Control->EVAL to insert a PHP code evaluation.
See How to evaluate a PHP commands to manipulate variables and clipboard (Experimental feature) for details on EVAL action.
EVAL error("Text 'Step 1' not found.")
Makes the test fail with “Text ‘Step 1’ not found.” as error message:
Example 1: Clipboard value
If you would like to assert that the clipboard contains value “Testing” use
EVAL $CLIPBOARD=="Testing"||error("Wrong value")
Example 2: Maximum loop passes
If you want to make sure that a loop does not run endlessly, you can limit the number of loop passes and make test fail after reaching the maximum number.
TAG#start
…some actions…
EVAL set("counter", get("counter") + 1) < 10 || error("Too many loops")
JUMP#start
PHP: Working with Dates
If you need to calculate days, you can perform that using the EVAL action.
See How to evaluate a PHP commands to manipulate variables and clipboard (Experimental feature) for details on EVAL action.
PHP syntax
Reference: https://php-legacy-docs.zend.com/manual/php5/en/function.date
date(format, date);
Code samples:
date('d.m.Y',strtotime("- 10 Days"))
date('d.m.Y',strtotime("yesterday"))
date('d.m.Y',strtotime("tomorrow"))
date('d.m.Y',strtotime("+ 3 weeks"))
date('d.m.Y',strtotime("- 2 Months"))
date('d.m.Y',strtotime("now"))
date('d.m.Y',strtotime("next Saturday"))
date('d.m.Y',strtotime("last Year"))
Example
1) Set a value to variable “days_before” in Editor->Data :
“days_before” = 10
2) Use EVAL in a test step with this constant:
EVAL "".date('d.m.Y', strtotime("-".${"days_before"}." Days") )
Running this EVAL action on today’s date 23.04.2022 results in a clipboard value 13.04.2022