Skip to content

Visual regression is flaky for pages with images #7342

@anandkedari

Description

@anandkedari

This issue is specific to pages which has screens and when we want to perform visual regression on page. This becomes significantly flaky for mobile native apps. Consider a situation where UI(web or mobile) fetches/downloads content through backend api or server. The content is downloaded at client and then the content is rendered at client i.e., on browser or native app. Let us also consider that the loader normally comes when api is triggered and goes away when the response is received.

Page with partially rendered image

The problem occurs when the image is downloaded and all api response is received from server, but while rendering on UI, there is a slight delay, probably 0.5 milisecond to 2 seconds. Since the DOM is fully loaded and there is no loader anymore, UI is available for interaction, thereby visual regression kicks-in and starts performing checkScreen flow. But the test becomes flaky when the image on screen is not yet fully loaded(downloaded but partially rendered). As there is a difference in baseline(fully loaded image) and actual runtime screenshot (partially rendered), tests becomes flaky. This is usually higher for native apps as few devices might take higher time to render the image thats already downloaded.

Which approach wouldn't work?

  • document.ready and img.complete is a very good alternative to tackle this, but this becomes difficult to handle on mobile native apps as these methods don't work there
  • waitFor visibility or interaction will not halt the visual comparison because logically DOM is loaded and elements are available for interactions. Even if we use wait on element, it will always return true as element is interactable
  • There is no way to interpret if image is fully rendered on page in native apps
  • Hard pause can solve the problem, but it has to be placed on each page where there are images in page. Eventually it will increase the execution time

Expected behavior
Can there be a away to add a capability that will halt visual regression till the page and images is fully loaded

Steps to reproduce :

Partially rendered image (Halt visual regression)

Page with partially rendered image

Fully rendered image (Perform visual regression)

Page with fully rendered image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs InvestigationIssues that require more information on the problem.help wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions