Verifications

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 and items 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.

Note:  

  • 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