SRF and Applitools

SRF enables you to include Applitools visual validations in tests running against or from SRF. When your SRF test run is complete, the visual validation step statuses and screenshots are also included in the SRF run results.

SRF supports the integration of Applitools with LeanFT or Selenium for JavaScript only.

Perform Applitools visual testing from SRF

Before you start running tests with Applitools visual testing steps, you must have:

  • An active Applitools account.

  • Correct Applitools API key provided for your Applitools account, defined in the SRF settings. For details, see Connect to Applitools.

Then, do any of the following:

Record Applitools steps

Add Applitools steps directly to your test while recording.

For details, see Record scripts.

Run tests with Applitools steps remotely

Upload tests with Applitools steps

To run Applitools validations as part of your LeanFT or Selenium test run, add explicit Applitools API calls to your scripts before uploading or running them remotely.

For details, see:

Access run results

After running your tests, either in SRF or remotely, view Applitools step results from the SRF run results.

For details, see Drill down to Applitools data.

Back to top

Add Applitools code to your LeanFT script

SRF supports Applitools with LeanFT scripts in JavaScript only.

Add code to your LeanFT test script to instruct SRF to report Applitools validations, while running remotely from LeanFT.

The following steps use JavaScript in the code samples.

Do the following:

  1. Add the following line to the start of your test:

    var EyesLeanFT = require('eyes.leanft');
  2. Then, add your Applitools steps. Use the following syntax:

     // Initialize the eyes SDK and set your private API key.
     var eyes = new Eyes();
     eyes.setApiKey("<YOUR_API_KEY>");
     eyes.setForceFullPageScreenshot(true);
    
     // Define the OS and open the Applitools session.
     eyes.setHostOS("<Operating system. For example: Windows 10>");
     eyes.open(browser, "<BATCH NAME>", "<TEST NAME>", { width: 800, height: 600 });
    
     browser.navigate("<URL to open. For example: https://www.applitools.com/helloworld>");
            
     eyes.checkWindow("<Applitools validation name. For example: Click>");
    
     // End visual testing. Validate visual correctness.
     return eyes.close(false).catch() // Make sure the next 'then' success callback always get called.
      .then(function () {
        eyes.abortIfNotClosed();
        LFT.cleanup();
      });
  3. Add additional code as required for all Applitools tests. For more details, see Applitools Resources.

For more details, see:

Back to top

Add Applitools code to your Selenium script

SRF supports Applitools with Selenium scripts in JavaScript only.

Add code to your Selenium test script to instruct SRF to report Applitools validations.

Use the following code snippet to get started:

driver.getSession()
.then(function(session) {
 eyes.addSessionEventHandler(RemoteSessionEventHandler.createSessionEventHandler(srfServer, session.getId())); 

Proxy settings

If you are working with a proxy, configure the proxy server using the Applitools Eyes SDK. Use the following method before starting an Eyes test:

Eyes.setProxy("http://YOUR-PROXY-URI", YOUR_PROXY_USER, YOUR_PROXY_PASSWORD)

Selenium and Applitools sample code

Update this code sample as follows before running your test:

  1. Update the following Applitools and SRF-specific values:

    applitoolsApiKey Enables snapshot recording for each visual validation performed in the test.
    srfServerUrl The URL of your SRF server.
    srfClientID / srfClientSecret

    Your SRF client secret values.

    For details, see Manage remote access.

    proxyUrl Required to run remote tests from behind a firewall.
  2. Comment out irrelevant code, depending on whether you're using a proxy, or running a remote or uploaded test.
  3. Update the environment capability values as needed.
  4. Update the test steps as needed.

For more details, see:

Back to top

See also: