From be91605c3c0f346470ceae0b1a1c3d77b2323e78 Mon Sep 17 00:00:00 2001 From: LingandRX Date: Sat, 9 Nov 2024 22:16:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Playwright=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=BB=A5=E5=A2=9E=E5=8A=A0=E8=B6=85=E6=97=B6=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E9=87=8D=E6=9E=84=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E4=BB=A5=E6=8F=90=E9=AB=98=E5=8F=AF=E8=AF=BB=E6=80=A7?= =?UTF-8?q?=E5=92=8C=E7=BB=93=E6=9E=84=E6=B8=85=E6=99=B0=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playwright.config.js | 6 ++++++ tests/hlk/demo.spec.js | 8 ++++---- tests/zhb/csv-demo.spec.js | 6 ++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/playwright.config.js b/playwright.config.js index 6025cbb..4ff0209 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -30,6 +30,12 @@ module.exports = defineConfig({ /* Reporter to use. See https://playwright.dev/docs/test-reporters */ reporter: 'html', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + timeout: 5 * 60000, + expect: { + toPass: { + timeout: 30000, + }, + }, use: { /* Base URL to use in actions like `await page.goto('/')`. */ baseURL: process.env.BASE_URL, diff --git a/tests/hlk/demo.spec.js b/tests/hlk/demo.spec.js index 6b6d4a1..c647c4b 100644 --- a/tests/hlk/demo.spec.js +++ b/tests/hlk/demo.spec.js @@ -8,11 +8,11 @@ test.describe const customer = new Customer(1, 1, { phone: phone }); console.log(`${customer.phone}-${customer.username}`); - test('创建顾客', async ({ touchCustomerPage }) => { - await touchCustomerPage.createCustomer(customer); - }); + test('登录touch和h5,创建顾客购买会员卡', async ({ touchPage, touchCustomerPage }) => { + await test.step('创建顾客', async () => { + await touchCustomerPage.createCustomer(customer); + }); - test('登录touch和h5,创建顾客购买会员卡', async ({ touchPage }) => { await test.step('在touch页面购买会员卡', async () => { await touchPage.getByText('去开单').click(); await touchPage.locator('.more > .icon > svg').click(); diff --git a/tests/zhb/csv-demo.spec.js b/tests/zhb/csv-demo.spec.js index 2d6c93a..780d1c9 100644 --- a/tests/zhb/csv-demo.spec.js +++ b/tests/zhb/csv-demo.spec.js @@ -65,8 +65,10 @@ test('csv', async ({ zhbPage }, workerInfo) => { .locator('span') .first() .click(); - await zhbPage.getByRole('button', { name: '完成开单' }).click(); - await expect(zhbPage.getByRole('button', { name: '结账' })).toBeVisible(); + await expect(async () => { + await zhbPage.getByRole('button', { name: '完成开单' }).click(); + await expect(zhbPage.getByRole('button', { name: '结账' })).toBeVisible({ timeout: 2000 }); + }).toPass(); await zhbPage.getByRole('button', { name: '结账' }).click(); await zhbPage.locator('#page_footBathPay').getByText('结算签字').click();