C# Code

The C# Code building block can be used to perform custom logical operations which are directly not available inside Leaptest such as parsing a json object, reading values from xml etc. The C# Code building block comes in handy for coders who love coding and want to handle their specific scenarios programmatically. With the help of C# programming skills one can have numerous opportunities while performing automation.

Fully expanded, the C# Code block shows the following properties:

Click to edit

Clicking this field opens up a popup which is an editor for C# code. A sample code snippet is also available which shows the entry point for code to be written. Write your code in this editor and press “Run” button to compile and execute it.

Text Fields

Add any number of fields that can contain dynamic content and be used as tokens. This is maintained in the form of Dictionary<string, object> These fields can be collected and typecast for their usage in C# code as required.

Error occurred:

The error occurred is an alternate flow which is triggered if there’s any runtime error detected during case execution.


The maximum time allowed for executing the code including the provided input and processing output. It triggers the “Error occurred” connector if the execution is unsuccessful within the specified time.

The default value is 60 seconds.

Note: All cases have a “global timeout” that can be configured in the “Settings” panel. This is unrelated to the timeout of a single building block. However, a running case will automatically be cancelled if it runs for longer than the global timeout.

Updated March 13th 2018.