如何在Playwright视觉比较中屏蔽多个定位器?

huangapple go评论224阅读模式
英文:

How to mask more than 1 locator in playwright visual comparison

问题

我想在使用Playwright进行视觉比较时屏蔽多个定位器,该如何操作?目前我只能屏蔽一个定位器。

我尝试了多个屏蔽命令,但没有起作用。

我想在使用Playwright进行视觉比较时屏蔽多个定位器,该如何操作?目前我只能屏蔽一个定位器。

我尝试了多个屏蔽命令,但没有起作用。

英文:

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

答案1

得分: 0

你可以将定位器数组传递给mask

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

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]});

huangapple
  • 本文由 发表于 2023年8月11日 15:17:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76881430.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定