The basic steps in Perfecto Automation scripts are execution of the Perfecto functions. To add a command step to the script double-click on a function in the Commands Sidebar display.
The Perfecto functions are arranged in two tabs:
After adding the command to the script it will appear as a new line in the Edit View of the Scripting Canvas.
After adding the commands to the script, set the values of the parameters for the particular function by double-clicking on the command line. This presents the Parameter window - this window is tailored to the command function that was selected, the following is just an example to highlight the main UI information:
The table in the window lists all of the basic parameters of the function. Some functions support "Advanced" parameters, that can be added to the table by checking the Show Advanced Parameters checkbox (upper left corner of window). To understand the use and range of values for the different parameters, click the Help button (lower right corner) to display the function description page from the Perfecto REST API documentation.
To set the value of one of the parameters -
Manage script variables from the Variables icon in the Automation toolbar.
Each script variable has:
To add/delete/move script variables, use the buttons located at the bottom right side of the window.
Runtime variables are defined by the user prior to running the script and their value may change during the execution. The value provided at definition time will be the default.
Deselect the check-box to explicitly define the variable's value which will be constant.
Encode confidential and sensitive information in scripts by encoding the text in following functions:
2. Enter the text to encode, and click on the Lock icon
3. Click on the Clipboard icon to copy the encoded text.
4. In the script, click on the function(s) which will use the encoded text. In the Text or Value parameter, select Type = Secured String, and paste the encoded text in the value field.
5. Run the script.
6. In the script report, the text will appear as encoded. The text will also be encoded in reports.
String Encoder and Execute Script
When using the Secured String type in a sub-script within script (execute script):
String Encoder and User Function
If a parameter is defined in a user function as Secured String type, when the user function is executed from within a script, the parameter type MUST be defined as Secured String.
If a parameter is defined in the user function as String type, when the user function is executed from within a script, the parameter type can be defined as either String or Secured String.
String Encoder and Selenium/Appium
When using the secured string in a Selenium/Appium automation script, prefix the encrypted string with "secured.". This provides indication to the Selenium/Appium Server that the string should be decrypted before transferring it to the device.
To include a condition into the script, use the Condition icon in the Automation toolbar. Use a condition to change the flow of the script according to a set criteria.
Each Condition splits the execution to two possible branches:
Conditions are evaluated according to the result of the preceding command, which should normally be a validation (such as Find or Text checkpoint). Therefore, ensure that the function to be evaluated is located directly above the condition in the script. (Notice that the results used to evaluate the condition can be from any function, including Wait.)
|Note: When using Find, the On Error policy (see below) is by default "Catch". When using a checkpoint, change the On Error policy to "Catch" rather than the default -exiting the script. This will avoid marking it as a pass or fail in the report, leaving it as the condition input only.|
Either conditional set of commands (On Success or On Failure) can be left blank, and if met will cause the script to continue to the next step after the condition statement.
It is possible to enter any set of commands inside the condition path - including nested conditions and groups (see below).
In the following script, the Condition command uses the result of the Text checkpoint to either click on the Login button or exit the script with an error.
Use loops in the script to repeat a set of commands - either a predetermined number of times or use a data table to create iterations and keep the script data driven.To add a loop to your script use the Loop icon on the Automation toolbar.
You can select what type of loop control from the Loop dialogue:
When repeat is selected, the system will iterate the command according to the defined number. When data table is selected, the system will perform the commands and in each iteration the data of the active row in the data table will be used.
How to use:
Note: A script can include multiple data tables. However, each loop can refer to only one data table.
Error policies such as Continue and Break change within a loop.
User functions enable branching in a script by different device criteria. The branches are packaged into reusable functions defined by the user – i.e. user functions. User functions "wrap" scenarios where there are differences across devices, maintaining one script for multiple devices.
How it Works
The user function contains an implementation script for each criteria. The function is run and when the rule is matched, the appropriate implementation script is run on the specific device.
It is recommended at this point to create the scripts you will be using for the user function.
Important: The parameters defined in your user functions are the run-time variables defined in your implementation script. The run-time variables of your implementation script should be identical and in the same exact order.
It is possible to add a default rule, that will run for all cases. To implement, open the User Function Rule and select an implementation script without selecting a device.
Validate the implementation script parameters
Note: You can access your implementation script in one click by using the Edit Script button.
Note: The parameters which appear in the user function are the run-time variables used in the implementation scripts.
Using the String Encoder in a user function:
Group existing script lines together by:
Edit the group name to describe the group. A group can also be included within another group.
A group is treated as a single unit. Groups may be used within branches of Condition statements, or as the iterated commands in a Loop.
The Perfecto Lab Repository is used to store files such as scripts, data tables, test flows, and images in the Perfecto Lab. Files, such as applications, can be stored in the Repository and later used within automation scripts.
The Repository is divided into the following areas:
|Data Tables||CSV or XML files that contain data for scripts|
|Media||Images, videos, text files, and applications|
|Test Flows||Test flows|
Each area is further divided into the following subareas:
|Public||Accessible by all users of the cloud|
|Group||Accessible by all users of a group. A single cloud can have multiple groups.|
|My||Private to the owner only|
Files can be uploaded, downloaded and deleted, by using the action icons at the bottom of the sidebar:
When using functions that utilize files from the repository, the paths to the files are specified as repository keys.
A repository key consists of the subarea and the path to the file. For example, to specify a file called myImage,jpg stored in the images folder located in the PRIVATE subarea, specify the key as PRIVATE:images/myImage.jpg.
A repository key does not need to contain the repository area in the path as it is inferred from the context. For example, in the repository key parameter of the Install application function, the repository area is automatically set to media.
Specify the command behavior if an error occurs during the command execution.
To do this:
It is possible to apply the error policy to multiple commands. All selected commands will receive the same error policy.
Available error policies:
The following keyboard shortcuts are available while working with the Automation tab in the Perfecto Lab IDE:
|HOME||Top of Script|
|END||End of Script|
|CTRL S||Save Script|
|DEL||Delete selected Line|
|CTRL G||Insert Group|
|CTRL O||Open Script|
|CTRL N||New Script|
|CTRL L||Insert Loop|
|CTRL P||Play (Execute Script)|
|CTRL V||Open Variables|
|CTRL F||Open Functions|
|CTRL D||Open Devices|
|Note: When using IE use CTRL+ALT, for the shortcuts that appear as "CTRL" in the table, to avoid conflicts with the browser's own shortcuts.|