PHP: How to manipulate with data (Experimental feature)

In Editor-> Control->EVAL create an EVAL action. This action can compute PHP functions using data from Control->Data and from CLIPBOARD.

EVAL argument is a PHP 5 expression. See on how to write php
The result of the expression is returned to the CLIPBOARD

Working with Data

Data from Data Tab in Editor can be read from the test to the clipboard.

E.g. setting

FirstName: Barbara
LastName: Mustermann
Age: 26

Read Data

EVAL $FirstName

Reads the value of the FirstName (“Barbara”) into the CLIPBOARD. Note that there is a “$” in front of the variable name using the EVAL command.

Manipulate Data

EVAL $FirstName." ".$LastName

Concatenates $FirstName, ” “, $LastName using the “.” as usual in PHP and returns the result to the CLIPBOARD.

Compute with Data

EVAL $Age + 10

Adds 10 to the variable Age. In the example with Age = 26, this command returns 36 to the CLIPBOARD.

PHP Examples

Measure time between steps

EVAL microtime(true)
EVAL microtime(true) -  $CLIPBOARD

Returns the time passes in seconds to CLIPBOARD.

Call PHP for TimeStamp

EVAL date_format(new DateTime(), "d.m.Y H:i:s");

Returns a timestamp to CLIPBOARD

Call Java for TimeStamp

EVAL new Java("java.util.Date")->toString();

Returns a timestamp to CLIPBOARD

Manipulate strings

EVAL substr($CLIPBOARD, 0,strlen($CLIPBOARD)-5)

Removes the last 4 characters from CLIPBOARD

Set and Get values from data store

EVAL set("result")

Sets the Clipboard value to a temporary result variable

EVAL set("result", "some value")

Sets a specific value

EVAL get("result")

Gets the current value.

EVAL set("result", get("result") ."\r\n". $CLIPBOARD)

Updates the result by concatenating the current value with a new one.

Free Webinar

Uncover the secrets of automated testing in the free webinar.