如何验证这些元素在 Playwright typescript 中具有相同的值?

问题描述 投票:0回答:1

我将这些元素放在一个页面中。我想使用剧作家检查 17 个警报与饼图下的 17 个警报具有相同的值

see this image

我还没有做任何事情,因为我不擅长编程,但我希望验证两个元素具有相同的值 17

见附图

蒂亚

testing automation playwright playwright-typescript
1个回答
0
投票

您可以(并且应该)为此使用断言。

例如:

const expectedText = "17"

const locatorA = await page.locator("<your_locator_here>");
await expect(locatorA).toHaveText(expectedText);

const locatorB = await page.locator("<another_locator_here>");
await expect(locatorB).toHaveText(expectedText);

另一种方法,您可以获取每个元素的文本并断言它们相等。

© www.soinside.com 2019 - 2024. All rights reserved.