【发布时间】:2021-09-01 03:52:20
【问题描述】:
我正在将 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"]');
});
});
问题是这 2 个测试并行运行,而 02 依赖于 01,因为需要登录。
如何让 2 个分组测试在同一上下文中运行?
【问题讨论】:
标签: node.js typescript automated-tests playwright