Skip to content

MarinaRukavitsyna/TestCafe-Screenshot-Testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Screenshot Testing with TestCafe

This compare-screenshots.js Node.js module will compare a model screenshot with a screenshot captuad with TestCafe. The code uses TestCafe and Rembrant for Node.js.

How it works

Every single run of the tests generates a screenshot of the tested page. This screenshot is then used to track changes and write screenshot-based tests. With this capability, you can generate reports with all the screenshots, and plug this into your Continuous Integration, by recording screenshots for the first time as base ones (or whenever you intentionally change them), and letting your continuous integration check against the recorded screenshots.

Creating a screenshot from within a test is very easy. You can do this using the [t.takeScreenshot( [path] )] action (https://devexpress.github.io/testcafe/documentation/test-api/actions/take-screenshot.html). Call this action when your page is set up to check the layout:

    await t
       .typeText('#developer-name', 'John Smith')
       .click('#submit-button')
       .takeScreenshot(testScreenshotPath);
    });

Preparation

Before running the application, configure your environment:

npm install

The TestCafe, Rembrant, Colors and UAParser modules will be installed automatically.

Launch the example

Open index.html and configure screenshotPath and modelPath if necessary. You only type a single command to begin testing.

testcafe chrome index.js -s screenshots

Result

TestCafe automatically starts browsers, runs tests, takes a screenshot and compares it with a model screenshot. The test result will be shown on a console.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published