top of page
90s theme grid background
Writer's pictureGunashree RS

Guide to Regions Check: Mastering Visual Testing with Applitools

Introduction

In the rapidly evolving world of software development, ensuring that your application delivers a seamless and consistent user experience across different devices and environments is crucial. Visual testing has emerged as a critical component of this process, allowing teams to catch visual bugs that functional tests might miss. However, modern applications often contain dynamic elements, such as varying data, shifting components, or animations, that can complicate visual testing. This is where regions check in Applitools comes into play.


Regions check is a powerful feature within Applitools Visual AI that allows you to apply different match levels to specific parts of your application’s UI. Whether you need to handle dynamic data, ignore certain regions, or manage components that shift position, regions check provides the flexibility you need to ensure your visual tests are both accurate and reliable.


In this comprehensive guide, we will explore the concept of regions check, its various applications, and how to implement it effectively using Applitools. Whether you’re a beginner or an experienced tester, this guide will provide you with the insights and tools you need to master regions check and enhance your visual testing strategy.



Understanding Regions Check in Visual Testing

Visual testing focuses on verifying the appearance and layout of an application’s user interface (UI). While functional testing ensures that the application works as expected, visual testing ensures that it looks as expected. However, visual testing presents unique challenges, especially when dealing with dynamic content, varying layouts, and interactive elements.


Regions Check in Visual Testing

Regions check addresses these challenges by allowing you to apply specific match levels to different areas of your UI. This means you can tailor your visual tests to account for elements that change frequently, such as dates or user-generated content, without compromising the overall accuracy of your tests.


Regions check is a powerful tool in the Applitools Visual AI platform, enabling teams to maintain high test coverage while minimizing false positives. By using regions check, you can focus on the parts of the UI that matter most and ignore or adjust for those that don’t, leading to more reliable and actionable test results.



The Importance of Match Levels in Regions Check

Match levels in Applitools define how strictly the Visual AI compares the current test result against the baseline. The three primary match levels are:

  1. Strict Match Level: This is the default and most stringent match level, comparing every pixel between the checkpoint and the baseline. It’s ideal for detecting even the smallest visual differences.

  2. Layout Match Level: This match level is more lenient and focuses on the layout and structure of the page rather than pixel-perfect matches. It’s useful for handling dynamic content like text that changes frequently.

  3. Ignore Colors Match Level: This match level ignores color differences between the checkpoint and the baseline, making it suitable for cases where color changes are expected but other visual aspects should remain consistent.

These match levels can be applied globally across an entire test or selectively to specific regions of the page using regions check. By applying different match levels to different parts of your UI, you can fine-tune your visual tests to balance sensitivity and robustness.



Types of Regions in Applitools

Applitools provides several types of regions that you can use in your visual tests, each serving a specific purpose. Understanding these types is crucial to effectively implementing region checks.


Match Level Regions

Match Level Regions allow you to apply specific match levels (Strict, Layout, Ignore Colors) to targeted areas of your UI. This is particularly useful when dealing with dynamic elements like tables, charts, or content blocks that update frequently.

For example, you can apply the Layout match level to a table that changes content but should maintain the same structure. This way, your test will pass as long as the layout remains consistent, even if the data within the table changes.


Ignore Regions

Ignore Regions and exclude specific areas of your UI from the visual comparison entirely. These regions are useful when you want to ignore content that isn’t relevant to the test, such as advertisements, timestamps, or user-generated content.

Ignore regions should be used sparingly and only when other match levels, like Layout or Ignore Colors, are insufficient. Overusing ignore regions can lead to missed visual bugs, so it’s important to apply them judiciously.


Floating Regions

Floating Regions provide flexibility for elements that move within a defined area. They allow you to specify a range within which an element can shift without triggering a visual bug. This is ideal for animated components, logos that shift position, or elements that change alignment based on screen size.

Floating regions consist of two parts: the target element and the bounds within which it can move. As long as the element stays within these bounds, the test will pass, even if its position changes.



When and How to Use Each Region Type

Different types of regions in Applitools serve different purposes, and knowing when to use each type is key to maximizing the effectiveness of your visual tests.


Strict Match Level

Use a Strict Match Level when you need a pixel-perfect comparison. This is suitable for critical UI elements that should not change, such as logos, buttons, or static content. Any visual discrepancy in these areas could indicate a bug, making strict matching essential.


Layout Match Level

The Layout Match Level is best used for dynamic data, such as tables, lists, or content blocks, where the structure matters more than the exact content. For example, if your UI displays user transactions that vary daily, applying the Layout match level ensures that your test focuses on the table’s layout rather than the data within it.


Ignore Colors

Apply Ignore Colors when color differences are expected but should not impact the test outcome. This is useful for testing across different themes (e.g., light vs. dark mode) or when elements like buttons change color based on user interaction.


Use Cases for Ignore Regions

Ignore Regions are ideal for excluding areas with content irrelevant to your test. Examples include dynamic advertisements, timestamped messages, or random user-generated content. By ignoring these regions, you avoid unnecessary test failures due to changes outside your control.


Applying Floating Regions

Use Floating Regions for elements that move within a specific range. For example, if you have a floating action button that shifts position based on screen size or a carousel that slides between images, floating regions allow you to account for this movement without flagging it as a bug.



Implementing Regions Check in Applitools

Regions check can be implemented either through the Applitools Test Manager or directly in your code using an Applitools SDK. Each method has its advantages, depending on your specific needs and workflow.


Using Applitools Test Manager

The Applitools Test Manager provides a visual interface for applying region checks directly to your test results. This is particularly useful for quickly adjusting match levels or adding ignore regions without modifying your code.


Steps to Apply Regions Check-in Test Manager:

  1. Open Your Test Result: Start by opening the test result in the Applitools Test Manager.

  2. Select the Region: Click the “Select Region” button to draw a rectangle around the area you want to modify.

  3. Choose the Match Level: From the dropdown menu, select the desired match level (Strict, Layout, Ignore Colors) or region type (Ignore, Floating).

  4. Save and Re-run: After applying the region, save your changes and re-run the test to see if it passes with the new configuration.


Using Applitools SDK

For more flexibility and scalability, you can apply regions check programmatically using the Applitools SDK. This approach allows you to define regions directly in your test scripts, making it easier to manage tests across different environments and projects.


Example Using Cypress with Applitools SDK:

javascript

describe('Test Bank App', () => {
    beforeEach(() => {
        cy.eyesOpen({
            appName: 'ACME Bank',
            testName: 'Bank - Match Level Regions'
        });
    });
    it('should capture dashboard', () => {
        cy.visit('https://sandbox.applitools.com/bank/dashboard?layoutAlgo=true');
        // Apply Layout match level to specific regions
        cy.eyesCheckWindow({ 
            tag: "Dynamic Dashboard",
           layout: [
                { selector: '.dashboardOverview_accountBalances__3TUPB' },
                { selector: '.dashboardTable_dbTable___R5Du' }
            ]
        });
    });
    afterEach(() => {
        cy.eyesClose();
    });
});

This script demonstrates how to use CSS selectors to define match-level regions programmatically, giving you greater control over your visual tests.



Advanced Strategies for Regions Check

As your application grows, so does the complexity of your visual tests. Leveraging advanced strategies for region checks can help you maintain comprehensive coverage without overwhelming your test suite.


Handling Dynamic Data

Dynamic data, such as dates, user IDs, or transaction details, can lead to frequent test failures if not managed correctly. Using the Layout Match Level for regions containing dynamic data ensures that your tests focus on structural consistency rather than content variations.


Dealing with Shifting Components

Components that change position based on user interaction or screen size can be challenging to test. Floating Regions are the ideal solution, allowing these elements to move within a predefined range without causing test failures.


Scaling Regions Check Across Multiple Tests

If you have multiple tests that require similar region configurations, consider using Auto Maintenance in Applitools Test Manager. This feature allows you to apply regions check at scale, reducing the need for repetitive manual adjustments and streamlining your testing process.



Best Practices for Regions Check-in Visual Testing

To maximize the effectiveness of regions check in your visual tests, follow these best practices:

  1. Start with a Baseline: Establish a baseline image that accurately represents the expected UI. This ensures that all future tests are compared against a reliable reference.

  2. Use Specific Match Levels: Apply the appropriate match level to each region based on its content and behavior. Avoid applying lenient match levels globally, as this can lead to missed bugs.

  3. Limit Ignore Regions: Use ignore regions sparingly and only when necessary. Overuse can lead to incomplete test coverage and missed visual discrepancies.

  4. Regularly Review and Update: As your application evolves, review and update your region check configurations to ensure they remain relevant and effective.

  5. Document Your Strategy: Maintain clear documentation of your region's check strategy, including which regions use specific match levels and why. This helps maintain consistency across teams and projects.


Regions Check-in Visual Testing


Common Challenges and Solutions


Challenge 1: False Positives Due to Dynamic Data

Solution: Apply the Layout match level to regions with dynamic data. This ensures that only structural changes trigger test failures, not content variations.


Challenge 2: Overlapping Regions

Solution: Ensure that regions do not overlap, as this can cause conflicts and unreliable test results. Use distinct selectors for each region or adjust region boundaries to avoid overlap.


Challenge 3: Inconsistent Test Results

Solution: Review your match level settings and ensure that the appropriate level is applied to each region. Also, consider environmental factors, such as screen resolution or browser settings, that may affect test consistency.



Integrating Regions Check with CI/CD Pipelines

Integrating regions check into your CI/CD pipeline ensures that visual testing is part of your continuous integration and deployment processes. This helps catch visual bugs early in the development cycle and prevents them from reaching production.


Example: Integrating with Jenkins

Here’s how you can integrate Applitools regions check into a Jenkins pipeline:

groovy


pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh 'npm install'
            }
        }
        stage('Test') {
            steps {
                sh 'npm run test:visual'
            }
        }
    }
    post {
        always {
            script {
                publishApplitoolsResults()
            }
        }
    }
}

This pipeline runs your visual tests as part of the CI process and publishes the results to Applitools Test Manager, where you can review them and apply region checks as needed.


The Future of Regions Check in Visual Testing

As applications become more dynamic and user interfaces more complex, the need for advanced visual testing strategies like region checks will only grow. Future developments in visual testing may include more sophisticated AI-driven region detection, better support for responsive and adaptive layouts, and deeper integrations with development and design tools.


Staying ahead of these trends will be crucial for teams that want to maintain high-quality user experiences across all devices and environments. Regions check will continue to be a cornerstone of visual testing, providing the flexibility and precision needed to handle the challenges of modern UI development.



Conclusion

Regions check is an indispensable tool for visual testing, allowing you to tailor your tests to the unique challenges of dynamic and complex UIs. By understanding and effectively applying match levels, ignore regions, and floating regions, you can significantly enhance the accuracy and reliability of your visual tests.


Whether you’re managing dynamic data, handling shifting components, or scaling your tests across multiple environments, region check provides the control you need to maintain high test coverage without sacrificing precision. By integrating regions check into your CI/CD pipeline and following best practices, you can ensure that your application delivers a consistent and polished user experience every time.



Key Takeaways

  • Regions check allows for precise control over visual testing by applying specific match levels to different UI regions.

  • Match levels like Strict, Layout, and Ignore Colors can be applied selectively to account for dynamic content and varying layouts.

  • Ignore regions and floating regions provide additional flexibility for handling irrelevant content and moving elements.

  • Applitools Test Manager and Applitools SDK offer robust tools for implementing region checks in your visual tests.

  • Integrating regions check into your CI/CD pipeline ensures continuous visual testing and early bug detection.



FAQs


Q1: What is the purpose of region check in visual testing?

A1: Regions check allows you to apply different match levels to specific areas of your UI, providing flexibility to handle dynamic content, shifting elements, and other visual changes without compromising test accuracy.


Q2: When should I use the Layout match level?

A2: Use the Layout match level for regions where the structure is more important than the content, such as tables or lists with dynamic data.


Q3: How do ignore regions work in Applitools?

A3: Ignore regions that exclude specified areas from visual comparison, useful for content irrelevant to the test, like ads or timestamps.


Q4: What are floating regions used for?

A4: Floating regions allow elements to move within a defined range without triggering a test failure, ideal for animations or responsive layouts.


Q5: Can regions check to be automated in a CI/CD pipeline?

A5: Yes, region check can be integrated into CI/CD pipelines using Applitools SDKs, allowing for continuous and automated visual testing.


Q6: How do I handle dynamic data in visual tests?

A6: Apply the Layout match level to regions with dynamic data, ensuring that your test focuses on structure rather than content changes.


Q7: Are ignore regions a good practice?

A7: Ignore regions should be used sparingly and only when necessary, as overuse can lead to missed bugs.


Q8: How do regions check to improve test accuracy?

A8: By allowing you to tailor match levels to specific regions, regions check reduces false positives and ensures that your tests focus on relevant visual changes.



External Sources


コメント


bottom of page