0

我正在尝试使用 for 循环多次执行测试。Playwright Testrunner 没有在 for 循环中识别测试。它给出消息“未找到测试”。

示例代码。

test.describe("功能:执行脚本", async() => {

test.beforeEach(({ page }) => {
    landingpage = new Landingpage(page);
});

const dm = 2;
for (let i = 1; i <= dm; i++) {
   
    test(`Execute script multiple times`, async () => {
        //test steps
        console.log(i)
    });
}; });
4

1 回答 1

0

首先,确保您的测试没有循环。然后您必须重命名测试的标题以使其独一无二。

  const dm = 2;

  for (let i = 1; i <= dm; i++) {

    // Add unique identifier        ↓
    test(`Execute script multiple ${i} times`, async () => {
      //test steps
      console.log(i)
    });
  };
于 2022-01-12T13:39:40.633 回答