Cursor-rules
PromptBeginner5 minmarkdown
Repo rules
- This provisioning code is designed to run on Manjaro Linux.
4
0. Always use TypeScript instead of vanilla JavaScript whenever possible.
Loading actions...
- This provisioning code is designed to run on Manjaro Linux.
Project Summary:
This guide outlines the project structure and provides step-by-step instructions for setting up the Geometry Tutor application.
getByTestId() locator method to target elements, unless absolutely unable to do so.
getByTestId() is not possible, then using a getByRole() locator is the next best option.getByRole() is not possible, then using a getByPlaceholder() or getByLabel() or getByAltText() locator is the next best option.getByPlaceholder() or getByLabel() or getByAltText() is not possible, then using a getByText() locator is the next best option.
getByText(), always use the { exact: true } option to avoid unwanted partial matches.getByText() is not possible, then use whatever locator Playwright allows you to use to target the element.
const exampleSignInButton = page.getByTestId("ExampleButton_signIn");
await exampleSignInButton.click();
DON'T:
await page.getByTestId("ExampleButton_signIn").click();
await expect(async () => {
await radioButton.click(); // locator defined outside this block
await expect(radioButton).toBeChecked();
}).toPass();
DON'T:
export async function radioButtonGroupClick(
page: Page,
urlToWaitFor: string, // The URL where the radio button is
radioButton: Locator,
errorTextTrigger: Locator // A button you can click that will throw error text if the radio button wasn't clicked
) {
await page.waitForURL(urlToWaitFor);
let iterationCounter = 0;
let errorTextIsVisible = await page.getByTestId("ErrorText").isVisible();
let buttonWasClicked = await radioButton.isChecked();
while (errorTextIsVisible || !buttonWasClicked) {
if (iterationCounter === 5) {
break;
} else {
iterationCounter++;
}
await radioButton.click();
buttonWasClicked = await radioButton.isChecked();
if (buttonWasClicked) {
await errorTextTrigger.click();
errorTextIsVisible = await page.getByTestId("ErrorText").isVisible();
}
}
}
The entry point to Playwright's documentation is here if you need to look available features: https://playwright.dev/docs/intro.tests/ directory.