LeanFT provides several methods in the SDKs that enable you to check the behavior and appearance of your application.

When these Boolean methods return a false value, the step and test fail, and the HTML report includes information about the step. However, unlike standard Asserts, no exception is thrown and the test does not stop running.

Note: When working with the JavaScript SDK, you can use the expect and verify functions to validate expected values. For details, see Setting up and working with the JavaScript SDK.

Verifying values in your application

To check that your application is behaving as expected, you can use the methods of the LeanFT Verify class to check expected values or items.  

For example, you can retrieve values or get objects from your application and then use the Verify class methods to check whether:

  • The value in your application is equal, not equal, greater than, or less than an expected value.
  • A retrieved string or collection contains an expected string or object.
  • Any provided Boolean statement is true.
  • A retrieved value or object in your application is empty or null or not empty/null.
  • Whether a string retrieved from your application starts with or ends with an expected string.

For details, see the Verifications namespace or package in the .NET SDK Reference or Java SDK Reference.

For JavaScript, see Setting up and working with the JavaScript SDK.

Back to top

Verifying the appearance of your application

To check that the objects in your application appear as expected, you can use the LeanFT VerifyImageMatch and VerifyImageExists methods, which are available for every test object.  

These methods compare an image you provide with a snapshot of object in the application, as it appears when the step is performed.

  • You can verify that the image you provide is contained somewhere within your application object.
  • You can verify that your application object is identical to the image you provide, or you can define acceptable tolerances or similarity levels.
  • You can also define a maskArea object that specifies areas to include and/or exclude from the image comparison, and then compare only the maskArea of each image.

The test results of all VerifyImage* steps display both the expected and actual images.

You can also use the LeanFT LocateImage and CompareImages methods from the ImageUtils class to compare any two provided images, with or without defined tolerances or mask areas.  These methods also return Boolean values, but a false return value does not affect the step or test status.


  • When providing images to any of the above methods, it's best to create the image object (system.drawing.image or java.awt.image) using a BMP or PNG image and not a JPG image. The JPG compression algorithm loses information, such that a comparison between captured images may fail even if the items being evaluated are actually identical.
  • Images can be displayed differently on different machines and operating systems because of different operations like stretching and resizing the image. Different resolution and font size can also effect on how the image looks like on different OSs and browsers.

    When designing or running tests on different operating systems, adjust the tolerance and similarity level for image verification accordingly.


For details, see the .NET SDK Reference or Java SDK Reference.

For JavaScript, see Setting up and working with the JavaScript SDK.

Back to top

Create custom verifications and display them in the test report

LeanFT includes a set of comprehensive methods that can be used for verifying values and images, as described in Verifying values in your application and in Verifying the appearance of your application. In some cases, you might want to include verifications in your script for which the Verify class does not have dedicated methods. In such cases, you can develop your own custom verification and use it in your scripts.

LeanFT enables you to extend its verification capability and display your own custom verification in your test report by using the reportVerification method in the Reporter class. This capability is supported for all SDKs:

.NET SDK Reference

Java SDK Reference

JavaScript SDK Reference

When running scripts that include calls to custom verifications, LeanFT treats these verifications as it does built-in verifications and displays the verification results in the test report in the same manner.

Note: when passing a status of Warning to Report.reportVerification, the status is presented in the report as Passed.

Custom verification example

The following Java example shows how to use a custom verification method that verifies a sum of numbers. In this case, it is used to sum the price of two items in a shopping cart in a retail application.

The method receives three parameters: the two numbers to sum and the total.

The method is called in the test script, and the arguments passed are fetched from the application using LeanFT API.


public void testTotalPrice() throws GeneralLeanFtException, ReportException {
	long price1;
	long price2;
	long totalPrice;
	// .
       // .
       // This is where you add code to: add two items to the shopping cart, find their price,
        //and update each item's price in the price1 and price2 variables.
       // Then go to the check-out page, find the total price, add update the totalPrice variable with this value.
      // .
       // .
       // The following code calls the custom verification method verifyTotalSumOfNumbers.
      // The verification name and description are set and then passed as arguments along with the price arguments.
	String verificationName = "Verify Total Price";
	String verificationDescription = "Verify that the total purchase price is indeed a sum of the items in the cart";
	verifyTotalSumOfNumbers(price1, price2, totalPrice, verificationName, verificationDescription); 
	// .
       // .
       // Continue test logic
       // .
       // .

// This is the implementation of the custom verification method
protected void verifyTotalSumOfNumbers(long num1, long num2, 
				long total, String verificationName, 
				String verificationDescription) throws ReportException{  
       // Create a VerificationData object and set its name, description and operation.
	VerificationData verificationData = new VerificationData(); = verificationName;
	verificationData.description = verificationDescription;
	verificationData.operationName = "totalSumOfNumbers";

	// Create the verification parameters, set their label and values.
	VerificationParameter verificationParameter1 = new VerificationParameter("First Number", num1);
	VerificationParameter verificationParameter2 = new VerificationParameter("Second Number", num2);
	VerificationParameter verificationParameter3 = new VerificationParameter("Actual Sum", total);

	// Add the verification parameters to the parameters list of the verificationData object.

	// Call a custom comparison method
       boolean sumMatches = (num1+num2 == total);
	// Check whether the sums match. If they do, return reportVerification with a passes status.
	// If not, return it with a failed status. The status is displayed in the test report.
      if (sumMatches){
		Reporter.reportVerification(Status.Passed, verificationData);
		Reporter.reportVerification(Status.Failed, verificationData);

The test report for this example will look like this:

Back to top