From my read of the docs, this should work, however the test sometimes passes and sometimes not, from the traces it seems the input does not get filled.
Thanks in advance.
test("should show an error with an invalid email", async ({ page }) => {
const email = "invalidemail";
const inputWrapper = page.getByTestId("newsletter-input");
const input = inputWrapper.getByRole("textbox");
await input.fill(email);
await page.getByRole("button", { name: "Sign Up" }).click();
await expect(
page.getByText("This field must be a valid email")
).toBeVisible();
});
This thread is trying to answer question "Why does a test sometimes pass and sometimes fail when trying to fill an input field using Playwright?"
Can you share the error or a sneakpeak of the trace?
https://playwright.dev/docs/api/class-page#page-wait-for-load-state
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].