new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Vitest · API reference · all subjects

locators and dom

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

locators.extend API for custom browser locators

The locators.extend API allows extending browser locators with custom methods. Custom locators can return a Playwright locator string, which will be scoped to the parent locator if one exists. The method receives the current locator context (this: Locator) and can chain other locator methods, enabling custom user events and complex locator logic.

Custom locators example with getByCommentsCount

Example of extending locators: locators.extend({ getByCommentsCount(count: number) { return `.comments :text("${count} comments")` } }). This returns a locator string that can be chained with other methods.

Custom locator with context and chaining

Example of custom locator with context access: locators.extend({ getByCommentsCount(this: Locator, count: number) { return this.getByRole('comment').and(this.getByText(`${count} comments`)) } }). This allows using regular locator methods to define the custom locator.

Custom locator with async user event

Example of custom locator with async method: locators.extend({ async clickAndFill(this: Locator, text: string) { await this.click(); await this.fill(text) } }). Can be called as: await page.getByRole('textbox').clickAndFill('Hello World').

page.frameLocator API for iframe element selection

The page.frameLocator method returns a FrameLocator instance that can be used to find elements inside an iframe. This API is only available with the playwright provider. Example: const frame = page.frameLocator(page.getByTestId('iframe')); await frame.getByText('Hello World').click()

page.mark and locator.mark APIs for trace annotations

The page.mark API adds markers to the Playwright trace in browser mode. Use await page.mark('label') to add a point marker, or await page.mark('label', async () => { /* code */ }) to group a whole flow under one named entry in the trace timeline.

Locator strict mode for webdriverio and preview

Locating elements is now strict by default in webdriverio and preview, matching Playwright behavior. If a locator resolves to multiple elements, Vitest throws a strict mode violation instead of silently picking one. Use { strict: false } option to opt out and return first match.

Give your agent this brain