Search code examples
playwright

How to mask more than 1 locator in playwright visual comparison


I would like to mask more than 1 locator in visual comparison using playwright ? How to do that ? Currently I can mask only 1 locator.

I tried more than 1 mask command, its not working

I would like to mask more than 1 locator in visual comparison using playwright ? How to do that ? Currently I can mask only 1 locator.

I tried more than 1 mask command, its not working


Solution

  • You can pass an array of locators to mask:

    const maskedElement1 = await page.locator('element1); 
    const maskedElement2 = await page.locator('element2); 
    await expect(page).toHaveScreenshot({mask: [maskedElement1,maskedElement2]});