剧作家未能捕捉到文字
playwright failed to capture text
我是 Javascript 和剧作家的新人。我按照 Getting Started 指南中的第一个示例使用以下代码:
const { test, expect } = require('@playwright/test');
test('basic test', async ({ page }) => {
await page.goto('https://playwright.dev/');
const title = page.locator('.navbar__inner.navbar__title');
await expect(title).toHaveText('Playwright');
});
然而,当我 运行 测试时,title
最终成为一个空字符串:
$ npx playwright test
Running 1 test using 1 worker
✘ tests/example.spec.js:3:1 › basic test (6s)
1) tests/example.spec.js:3:1 › basic test ========================================================
Error: expect(received).toHaveText(expected)
Expected string: "Playwright"
Received string: ""
Call log:
- waiting for selector ".navbar__inner.navbar__title"
4 | await page.goto('https://playwright.dev/');
5 | const title = page.locator('.navbar__inner.navbar__title');
> 6 | await expect(title).toHaveText('Playwright');
| ^
7 | });
8 |
9 |
at /Users/h.vu/Downloads/node/playwright/tests/example.spec.js:6:25
at runNextTicks (node:internal/process/task_queues:61:5)
at processImmediate (node:internal/timers:437:9)
at WorkerRunner._runTestWithBeforeHooks (/Users/h.vu/Downloads/node_modules/@playwright/test/lib/workerRunner.js:499:7)
1 failed
tests/example.spec.js:3:1 › basic test =========================================================
呼叫日志,根据输出显示,正在等待选择器“.navbar__inner.navbar__title”,我认为这可能是一个时间问题。感谢您帮助完成此测试 运行。谢谢。
定位器中需要空 space:
const { test, expect } = require('@playwright/test');
test.only ('basic test', async ({ page }) => {
await page.goto('https://playwright.dev/');
const title = page.locator('.navbar__inner .navbar__title');
await expect(title).toHaveText('Playwright');
});
('.navbar__inner .navbar__title');
在
之间有空 space
我是 Javascript 和剧作家的新人。我按照 Getting Started 指南中的第一个示例使用以下代码:
const { test, expect } = require('@playwright/test');
test('basic test', async ({ page }) => {
await page.goto('https://playwright.dev/');
const title = page.locator('.navbar__inner.navbar__title');
await expect(title).toHaveText('Playwright');
});
然而,当我 运行 测试时,title
最终成为一个空字符串:
$ npx playwright test
Running 1 test using 1 worker
✘ tests/example.spec.js:3:1 › basic test (6s)
1) tests/example.spec.js:3:1 › basic test ========================================================
Error: expect(received).toHaveText(expected)
Expected string: "Playwright"
Received string: ""
Call log:
- waiting for selector ".navbar__inner.navbar__title"
4 | await page.goto('https://playwright.dev/');
5 | const title = page.locator('.navbar__inner.navbar__title');
> 6 | await expect(title).toHaveText('Playwright');
| ^
7 | });
8 |
9 |
at /Users/h.vu/Downloads/node/playwright/tests/example.spec.js:6:25
at runNextTicks (node:internal/process/task_queues:61:5)
at processImmediate (node:internal/timers:437:9)
at WorkerRunner._runTestWithBeforeHooks (/Users/h.vu/Downloads/node_modules/@playwright/test/lib/workerRunner.js:499:7)
1 failed
tests/example.spec.js:3:1 › basic test =========================================================
呼叫日志,根据输出显示,正在等待选择器“.navbar__inner.navbar__title”,我认为这可能是一个时间问题。感谢您帮助完成此测试 运行。谢谢。
定位器中需要空 space:
const { test, expect } = require('@playwright/test');
test.only ('basic test', async ({ page }) => {
await page.goto('https://playwright.dev/');
const title = page.locator('.navbar__inner .navbar__title');
await expect(title).toHaveText('Playwright');
});
('.navbar__inner .navbar__title');
在