playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Question] Visual testing: How can I ignore a specific region in Visual testing

Open ShanmukhaGajula opened this issue 4 years ago • 15 comments

[Question] Visual testing: How can I ignore a specific region in Visual testing, say I want to ignore a tag where there is dynamic content like visitor number to the page and timestamp when we visit the page. And there is another scenario where I will get the application number upon the submission of a form, I need to do the visual testing of the page by ignoring that tag which has data of application number.

Thanks in advance and kudos to all for the 1.20version release.

ShanmukhaGajula avatar Mar 16 '22 09:03 ShanmukhaGajula

I can see there is a mask feature, will this work here? if this works is there any way that I can see that data without masking it?

ShanmukhaGajula avatar Mar 16 '22 09:03 ShanmukhaGajula

Mask will work for you, but it'll hide the content. We were planning a feature like the one you are asking for, that ignores region while comparing, yet shows the content in the screenshot.

pavelfeldman avatar Mar 16 '22 14:03 pavelfeldman

That's really great.. Thank you..

ShanmukhaGajula avatar Mar 16 '22 14:03 ShanmukhaGajula

Hello,

I have similar requirement. one of our page is having very dynamic data similar like a flight search result which can differ everyday as per date.

can you please help which method can help us? if i use mask , i need to add many css, will above discuss feature ignore region work in this case?

can you please help me in this?

goyalshweta017 avatar Apr 06 '22 11:04 goyalshweta017

@pavelfeldman , @mxschmitt mask have a solid color. This works great in many scenarios, but if the bounding box of the masked elements changes between the golden and candidate screenshot, Playwright will yield a false negative diff.

Can we add an option to the mask to apply visibility: hidden; on the locators instead or adding some solid color highlights to overlay them ?

p01 avatar Apr 20 '22 13:04 p01

Hello @aslushnikov, @pavelfeldman , @mxschmitt I have a case where a mask element has different size between the reference screenshot and the actual one.

Option to ignore the size/pixels difference of a mask element would be great addition.

NikkTod avatar Nov 02 '22 08:11 NikkTod

@mxschmitt @pavelfeldman @aslushnikov I have a similar requirement where the values are dynamic. Is the mask option available in the latest releases?

sharath2106 avatar Dec 10 '22 16:12 sharath2106

@pavelfeldman @aslushnikov - Hi team, kudos for the great work so far. Is there any update on the below feature , will it be available in future releases?

Mask will work for you, but it'll hide the content. We were planning a feature like the one you are asking for, that ignores region while comparing, yet shows the content in the screenshot.

rick47-curious avatar Feb 20 '23 20:02 rick47-curious

Bumping the thread again, any updates on when this feature is likely to rollout? We are using Playwright for our tests and this feature is really needed for us.

sharath2106 avatar Mar 02 '23 08:03 sharath2106

Bumbing this thread too. We have many Tables in our Project with changing Datasets. This feature would help us a lot.

SirCmX avatar Mar 27 '23 09:03 SirCmX

I worked around the need to mask a dynamic region by running JavaScript to hide the matching selector. Not ideal, but it worked well enough for my purposes.

mscottford avatar Jul 31 '23 16:07 mscottford

Any update on this ? How to ignore region that has dynamic content ?

anbhattacharjee avatar Aug 10 '23 18:08 anbhattacharjee