当我在PLAYRITRITE中运行测试时,断言总是失败.它与h2元素不匹配,即使页面确实显示了它.
我的测试代码:
import { test, expect } from '@playwright/test';
test('Thomann', async ({ page }) => {
await page.goto('https://www.thomann.de/intl/index.html');
await page.locator('xpath=/html/body/div[2]/div/div/div/div[2]/button[1]').click();
await expect(page.getByRole('heading', { name: 'Nuestras categorías' })).toBeVisible();
});
日志(log)错误:
Error: Timed out 5000ms waiting for expect(locator).toBeVisible()
Locator: getByRole('heading', { name: 'Nuestras categorías' })
Expected: visible
Received: hidden
Call log:
- expect.toBeVisible with timeout 5000ms
- waiting for getByRole('heading', { name: 'Nuestras categorías' })