Create tests

In this chapter, you’ll learn how to create tests using the Applitools Eyes integration in Ranorex Studio.

In this chapter

    Prepare the test suite

    In the test suite view, right-click the test suite and click Add setup. Repeat for Add teardown.

    From the module browser, drag and drop the InitializeEyes code module to the setup region and the FinalizeEyes module to the teardown region.

    Right-click the test suite and click Global parameters…

    In the dialog that appears, click Auto-create and then Auto-bind.

    Next to EyesApiKey, enter your Applitools Eyes API key. If you’re using an on-premise installation, enter the URL to the server in ServerURL. You can also define other parameters here, but they are optional. See below for an explanation of what they do.

    AppName: Enter the name you want the test to be saved under in the Apps & tests category in Eyes.

    EyesBatchId: Enter the ID of a test batch to always pass results to this batch.

    ViewPortWidth: Define a custom width in pixels for the Applitools Eyes viewport .

    ViewPortHeight: Define a custom height in pixels for the Applitools Eyes viewport.

    MatchLevel: Define the match level that will be used. Possible values: Exact, Strict, Layout, Content. Default is Strict.

    Build your test

    You can now build your test as usual and add visual checks by Applitools Eyes to it. This is done in recording modules through user code methods.

    Open the recording you want to add a visual check to.

    Drag and drop the repository item you want to check from the repository to the desired position in the action table.

    In the context menu that appears, click User code > Select from library.

    Double-click the VisualCheckpoint method.

    Note icon

    Note

    • You can perform visual checks on any repository item, from complete websites to single buttons.
    • You can add as many visual checks as you like, but each check will take additional time and slow down your tests because image data needs to be passed to Applitools Eyes.

    Reference

    Find out more about user code methods and the user code library in Ranorex Studio expert > User code library > ⇢ Introduction

    Other Applitools user code methods

    Aside from VisualCheckpoint, there are several more user code methods you can add to a recording module. Use them to pass custom Applitools Eyes parameters at runtime. These will overrule global parameters you’ve set. Refer to the descriptions in Ranorex to see what they do. To add them:

    Open the recording you want to add the method to.

    In the action table, click Add new action > User code > Select from library.

    Double-click the desired user code method.

    In the action table, enter your value for the required argument.

    PDF and image file checks

    You can also use the Applitools Eyes integration to perform visual regression tests on PDF and image files. There is a special user code method for this purpose.

    Open the recording you want to add a file check to.

    In the action table, click Add new action > User code > Select from library.

    Double-click VisualCheckpoint(String fileORFolderPath).

    In the action table, enter the value that points to the file or folder you want to check. The following formats are possible:

    • Absolute, e.g. C:usersuserdocumentsMyPDF.pdf for a single file or C:usersuserdocuments for an entire folder.
    • Relative, e.g. MyPDF.pdf for a single file or documents for an entire folder. Relative paths only work for files and folders in the same location as the test executable.