What the gym trains
Writing a locator is the most frequent small task in UI test automation, and the one where hesitation shows. In a coding round you are often given a page and asked to find an element that has lookalikes: two Delete buttons, a footer link that repeats a header link, a checkbox whose label contains another checkbox’s label. Each drill here is one of those moments, with a minute on the clock.
Your locator is evaluated against the page shown, in your browser. In Playwright it passes when it resolves to exactly the outlined element. In Selenium it passes when the first match, which is what findElement returns, is the outlined element. You earn points for speed, and extra points for a sturdy locator: in Playwright one built from roles, labels, text or test ids instead of a CSS or XPath fallback, in Selenium one that does not depend on position.
How scoring works
- 100 points for a correct locator, plus up to 50 for the time left on the clock.
- 25 bonus points for a sturdy locator. In Playwright that means
getByRole,getByLabel,getByText,getByPlaceholder,getByAltText,getByTitleorgetByTestIdwithout.locator(). In Selenium it means no positional parts: no[2]index,nth-child,last()or sibling axes. - 20 points off for each wrong attempt. A skip or a timeout scores nothing.
- The daily set is the same eight drills for everyone on the same UTC date, easiest first. Finish it every day to build a streak.
The ideas behind most drills
- **Say what it is, not where it is.**
getByRole('button', { name: 'Save' })survives a redesign;.locator('div > div:nth-child(3) button')does not. See the Playwright locators lesson. - **Narrow before you look.** When the same button repeats, find the row or card with
filter({ hasText })and then look inside it. - **Exact beats partial when names overlap.** "Next" also matches "Next steps".
exact: trueremoves the ambiguity. - **Hidden elements are not in the accessibility tree.** Role locators skip them, so you rarely need
.first()to dodge a hidden duplicate. - **Landmarks and labels separate lookalike regions.** Footer links, a second navigation and dialogs are told apart by their role and accessible name.
Selenium locators in the gym
Switch the language at the top of the gym to practise driver.findElement(By.id(...)), By.name, By.cssSelector, By.linkText and By.xpath, including chains such as findElement(...).findElement(...). Selenium has no roles or labels, so lookalikes are told apart by attributes, by the text of an ancestor in XPath, or by a CSS scope such as footer a[href]. The same drills and the same daily set are used, with their own results.
Every Selenium model answer is checked in a real browser with WebDriver semantics: the locators are evaluated in order and the first match must be the target.
How this differs from real Playwright
The gym uses SDETRole’s own locator engine, which implements a subset of Playwright’s locator semantics: the getBy* methods, locator(), filter, first, last, nth, and, or and chaining. Every model answer in the gym is also resolved with real Playwright in our test suite, so what is marked correct here works in a real run. Only the locator is checked: do not add click() or an assertion.
Frequently asked questions
Can I practise Selenium locators here?
Yes. Choose Selenium (Java) at the top of the gym. You write driver.findElement(By...) expressions, optionally chained, and they are checked against the page in your browser. Nothing is sent to a server, and no Selenium or Java is installed.
Is this the real Playwright?
No. Your locator runs on SDETRole’s locator engine, a subset of Playwright’s locator API, against a small page in your browser. The model answers are verified against real Playwright, but a real browser run is not involved. Nothing is sent to a server.
Why does my locator count as correct but get no bonus?
The bonus is for user-facing locators. If you used .locator() with CSS or XPath, or none of the getBy methods, the locator is correct but not idiomatic. Try getByRole, getByLabel or getByTestId with filter for scoping.
What does “strict mode violation” mean?
A Playwright locator that matches more than one element throws when you act on it, for example click(). The gym treats a locator that matches extra elements as wrong for the same reason.
How is the daily set chosen?
The set is picked from the date (in UTC) with a fixed algorithm, so everyone gets the same drills on the same day and no server is needed.
Is my progress saved?
Your best score, daily results and streak are saved in this browser only.