Skip to main content

Execute Script

This command executes a custom .NET script, which is useful in these scenarios:

  • Control the command execution flow

  • Check for duplicates

  • Manual interaction with the agent web browser. 

Click the Script type drop-down to choose a script containing typical functionality. You can use a script just as it is given in the template, or click the Edit Custom Script button to launch a pop-up window to edit the script according to your requirements.

Example

Below screenshot shows the simplest example where the Execute Script command can be used.

ExecuteScriptExample.png

Each script command has a corresponding web element selection, and this element has a corresponding entry in the custom script. At run time, if the selection does not exist on the web page, the web element will be NULL in the script. You can check for NULL elements in the script and execute custom functionality if a NULL is found.

Predefined Scripts

Click the Script type drop-down to choose a script containing typical functionality. You can use a script just as it is given in the template, or click the Edit Custom Script button to launch a pop-up window to edit the script according to your requirements.

Exit on Duplicate Data

Choose Exit on Duplicate Data in the Script type drop-down to select a script that will examine the data extraction up to a specific point and check for a matching data row. If a duplicate is found, the agent exits a specified container command.

If you want to check for duplicates in the data extraction from a previous agent run, you must ensure that the agent does not replace data every time it runs. This is done on the Internal Database window - which you can open from the Data menu.

ExitOnDuplicateData_10_D.png

See Removing Duplicate Data andExtracting New Data Only for more information about how this script can be used.

Copy Duplicate Data

Choose Copy Duplicate Data in the Script type drop-down to select a script that will examine the data extraction up to a specific point and check for a matching data row. If a duplicate is found, the agent will copy the duplicate data and all child data to the current data row, and then exit a specified container command.

If you want to check for duplicates in the data extraction from a previous agent run, you must ensure that the agent does not replace data every time it runs. This is done on the Internal Database window - which you can open from the Data menu.

CopyDuplicateData_10_D.png

SeeReusing Existing Datafor more information about how this script can be used.

Copy & Delete Duplicate Data

Choose Copy & Delete Duplicate Data in the Script type drop-down to select a script that will examine the data extraction up to a specific point and check for a matching data row. If a duplicate is found, the agent will copy the duplicate data and all child data to the current data row, and then delete the existing data row, and lastly exit a specified container command.

If you want to check for duplicates in the data extraction from a previous agent run, you must ensure that the agent does not replace data every time it runs. This is done on the Internal Database window - which you can open from the Data menu.

CopyAndDeleteDuplicateData_10_D.png

Exit Command

This script exits a container command when a specific condition is met. 

Exit Command & Delete Data

This script deletes the current data row and then exits a container command when a specific condition is met.

ExitCommand_10_D.png

Retry Command

This script retries a container command when a specific condition is met. You can control the number of times that the agent will retry a container command by editing the default script and using the Retry Count value in the script parameters.

RetryCommand_10_D.png

Restart Agent & Continue

This script restarts the entire agent and continues where it left off when a specified condition is met.

RestartAgent_10_D.png

Typically, you would use this script to completely reset a web browser after an error occurs. The agent continues exactly from the point before the reset, so that if an error keeps occurring at this point, the agent will keep restarting in an infinite loop. To avoid this problem, you can set the status Failed on the current data row, so the agent will move to the next data item when it restarts. This code snippet example sets the data row status to Failed.

args.DataRow.SetStatus(RowStatus.Failed)

Restart Agent & Retry:

The "Restart Agent & Retry" script is quite similar to "Restart Agent & Continue", but with one important addition. It not only restarts the agent and continues from where it left off but it also retries any errors for the specified number of times, as indicated in the Retry Count value, before the agent restarts. 

It serves the same purpose of resetting the browser after an error, and you can set the data row's status to "Failed" to prevent looping errors and to ensure the agent moves on to the next data item when it restarts. This code snippet example sets the data row status to Failed.
args.DataRow.SetStatus(RowStatus.Failed)

Pause Agent

This script pauses the agent when a specified condition is met. The agent will display the web browser and allow a user to manually interact with the web browser. The user can press the Continue button to continue processing.

PauseAgent_10_D.png

Script Return Value

An Execute Script command can control the command execution flow by its return value. The command returns an instance of a class CustomScriptReturn. This class has the following 4 public static methods:

Method

Description

static CustomScriptReturn RetryContainer(IContainer container)

The agent will retry the specific container command. The container command must be a parent of the current command.

static CustomScriptReturn ExitContainer(IContainer container)

The agent will exit the specific container command. The container command must be a parent of the current command.

static CustomScriptReturn Pause()

The agent pauses and displays an agent web browser, which allows a user to interact with the web browser before continuing processing.

static CustomScriptReturn Empty()

The agent continues its normal executing flow.

 

Command Properties

Command

Command Description: A custom description for the command. Default value is Empty.

Command Transformation Script:  A script used to change command properties at run time. The default value is disabled.

Disabled: This property set to True allows user to disable the command. A disabled command will be ignored. The default value is set to False.

ID:  This property indicates the internal unique ID of the command and is always auto- generated e.g. 58c8e4ac-e4c0-48f7-a63d-77064945380b.

Increase Data Count: This property indicates the data count every time this command is processed. The default value is set to False. Set it to TRUE if you want to get the count of the number of times a specific command is executed to get the data. The data count value is increased during data extraction, so it is used to measure agent progress and basis this increased data count, the agent  decides the success criteria.

Name:  This property specifies the name of the command.

Notify On Critical Error:  A notification email is sent at the end of an agent run if the command encounters a critical error, and the agent has been configured to notify on critical errors. Critical errors include page load errors and missing required web selections. Default value is set to False.

Command Script

Default Script Condition: Specifies condition parameters for default scripts.

  •  Command:   The command to action on.

    • Agent: Action on Agent Command.

    • Parent Command: Action on Parent Command.

    • Parent List Command: Action on Parent List Command.

    • Parent List Entry: Action on Parent List Entry.

    • Parent Pagination Command: Action on Parent Pagination Command.

    • Specific Command: Action on a specific command which is specify in “Specific command”.

  • Retry Count: Specifies the number of times a container command should be retried if the script type is set to  "Retry Command" . A value of 0 means indefinitely.

  • Selection Condition:  The condition for actioning.

  • Specific command:  A specific command to action on.

Script: The command script.

  • C# Script: Specifies C# script.

  • Enabled: To use the Script we need to set this Property as True. The default value is set to False, which indicates that the script is disabled.

  • Library Assembly File: The name of a custom assembly file when "Use Default Library" is set to false.

  • Library Method Name: The method to execute when using the default script library.

  • Library Method Parameter: A custom parameter passed to the script library method.

  • Python Script: Specifies Python script.

  • Regex Script: Specifies Regex script.

  • Script Language: Specifies the scripting language which you want to use e.g C#, VB.NET , Python, Script Library, Regular Expressions.

  • Template Name: The template name of the referenced template.

  • Template Reference: Loads this script from a template when the agent is loaded.

  • Use Default Library: Uses the default script library when Script Language is set to Script Library.

  • Use Selection: The script is provided with the selected web element. The script will not be provided with the selected web element if this value is False.

  • Use Shared Library: Uses a script library that is shared among all agents.

  • VB.NET Script: Specifies VB.NET script.

Script Type:  The type of script. For example custom, Exit On duplicate data, Copy Duplicate Data, Copy & Delete Duplicate Data, Exit Command, Exit Command & Delete Data, Retry Command.

Selection

  • Selection: The selection XPaths of the web elements associated with this command.

    • Paths:  List of selection XPaths.

      • Path:  The selection XPath.

  • Select Hidden Elements:  Selects visible and disabled elements when true. Otherwise selects only visible and enabled web elements.

  • Selection Missing Option:  Specifies what happens if this selection does not exist in the current page.

    • Default: Specifies if  this selection does not exist in the current page then logs error. 

    • Ignore Command but Execute Sub-Commands: Specifies if  this selection does not exist in the current page then it ignores the current command , but executes sub-commands of the command.

    • Ignore Command: Specifies if  this selection does not exist in the current page then it ignores the current command as  well as sub-commands.

    • Log Error and Ignore Command: Specifies if  this selection does not exist in the current page then it ignores the current command as  well as sub-commands and logs an error message.

    • Log Warning and Ignore Command: Specifies if  this selection does not exist in the current page then it ignores the current command as  well as sub-commands and logs a warning message. Note: Warning message will be logged if , Log level is set to either ‘Low’ or ‘High’.

    • Log PageLoad Error and Ignore Command: Specifies if  this selection does not exist in the current page then it ignores the current command as  well as sub-commands and logs a Page Load error.

Debug

Debug Break Point: Debugging will break at this command if the break point is set. Default value is set to False.

Debug Disabled: A disabled command will be ignored during debugging. Default value is set to False.

Debug Error Option: This property specifies what action to take when an error occurs in the debugger. Default value is set to Notify which indicates that when an error occurs at debugging time , then it will be notified. If we want to ignore the error at debug time , then we need to set this property value as Ignore.

Export

Export Enabled: A command with Export Enabled set to false will not save any data to data output. Default value is set to True which indicates that any data will be saved to a data output.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.