Skip to content

Samples

Philipp Stracker edited this page Aug 13, 2021 · 3 revisions

Sample 1

Sample scenario that tests the Google search page:

Scenario('Visual Test', async () => {
    I.amOnPage('https://google.com');
    
    // accept privacy policy popup.
    I.waitForElement('#L2AGLb');
    I.click('#L2AGLb');
    
    // Prepare the visual-test configuration.
    const options = {
        tolerance: 2,
        bounds: {
            left: 10,
            top: 10,
            width: 99999,
            height: 600
        }
    };
    
    // Generate the expected base image.
    await I.takeScreenshot('google-page', 'expected');
    
    // After generating the screenshot/base/google-page.png file
    // You can comment out the above line. Edit that base image
    // And run the test again to see the results.
    
    // Take a snapshot of the current page to test.
    await I.takeScreenshot('google-page');
    
    // Compare both images and process the results.
    const res = await I.getVisualDifferences('google-page', options);
    console.log(JSON.stringify(res));
    
    // Compare both images with an assertion.
    await I.checkVisualDifferences('google-page', options);
})

← Comparison Results | Using Folders →