Playwright locators are a way of finding and interacting with elements on a web page. These can be used to perform actions, such as clicking, filling, checking, etc., or assertions, such as expecting text, visibility, or state.
Built in locators
page.getByRole(): To locate by explicit and implicit accessibility attributes.
page.getByLabel(): To locate a form control by associated label's text.
page.getByPlaceholder(): To locate an input by placeholder.
page.getByAltText(): To locate an element, usually image, by its text alternative.
page.getByTitle(): To locate an element by its title attribute.
page.getByTestId(): To locate an element based on its data-testid attribute.
data-testid attributes are custom attributes that can be added to HTML elements to identify them for testing purposes. They are not part of the HTML specification, but they are commonly used in testing frameworks and tools to locate and interact with elements on web pages.
data-testid attributes can be added to any HTML element, such as <div>, <span>, <input>, and so on. The attribute value can be any string that is meaningful to the developer or tester, such as "login-button", "dropdown-menu", or "product-description". The goal is to provide a consistent and reliable way to identify elements for testing.
If we absolutely must use CSS locators in the absence of data-testid attributes, we can use page.locator() to create a locator that takes a selector describing how to find an element in the page.
There is nothing to commit in here. If you have made some changes to the project, clean them up by executing the following command.