小编Amr*_*rou的帖子

使用 Playwright 按顺序运行分组测试

我将 Playwright 与 Nodejs 一起使用,并且将几个测试分组在一起,如下所示

import { test, expect } from '@playwright/test';

test.describe('Add a simple invoice test', () => {
    test('01.Login & add an invoice', async ({ page }) => {
        await page.goto("https://someUrl.com");
        await page.fill('input[id="email"]', "someEmailAddress");
        await page.fill('input[ng-model="ctrl.user.password"]', "somePassword");
        await page.click('button[id="login-btn"]');
    });

    test('02.Add an invoice', async ({ page }) => {
        await page.click('[name="invoice"]');
        await page.click('button[id="addInvoiceButton"]');
        await page.click('a[ng-click="ctrl.goToAddInvoice()"]');
        await page.fill('#invoiceTitle', Math.random().toString(36).substring(7));
        await page.fill('#exampleInputAmount', "120");
        await page.click("#invoiceCategory")
        await page.fill("#invoiceCategory > input", "Car")
        await page.keyboard.press("Enter");
        await page.click('button[id="submitInvoiceButton"]');
    });
});
Run Code Online (Sandbox Code Playgroud)

问题是这两个测试并行运行,而 02 依赖于 01,因为需要登录。 …

automated-tests node.js typescript playwright

14
推荐指数
3
解决办法
2万
查看次数

标签 统计

automated-tests ×1

node.js ×1

playwright ×1

typescript ×1