我正在try 使用编剧打字脚本创建一个基本的注册脚本.如果我使用调试模式并单步执行代码,它运行得很好,但如果我使用Headless,它就失败了.try 填写邮箱字段时失败.我正在使用的定位器能够找到元素,但它会try 等待它可见,即使它出现在页面上.Html上没有iframe.
import { test, expect, Locator, Page } from '@playwright/test';
class RegisterStr{
userName: Locator;
pw: Locator;
button: Locator;
constructor(page: Page){
this.userName = page.locator('#username')
this.pw = page.getByLabel('#password')
this.button = page.locator("#submit")
}
}
test.describe("Resgietring", ()=>{
let regis : RegisterStr;
test('has title', async ({ page }) => {
regis = new RegisterStr(page)
await page.goto('https://practicetestautomation.com/practice-test-login/');
regis.userName.fill("student")
regis.pw.fill("Password123")
regis.button.click();
// await page.waitForURL("https://practicetestautomation.com/logged-in-successfully/")
// Expect signed in
await expect(page.getByRole('heading', { name: 'Logged In Successfully' })).toBeVisible();
});
})