new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Playwright · API reference · all subjects

frame/methods

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

Frame.waitForFunction() expression parameter

Frame.waitForFunction() takes an expression parameter that is JavaScript code or a function to evaluate. The method waits until this expression returns a truthy value.

Frame.waitForFunction() arg parameter

Frame.waitForFunction() has an optional arg parameter of type EvaluationArgument that is passed to the expression. Available since v1.8.

Frame.waitForFunction() - returns JSHandle

Frame.waitForFunction() is an async method available since v1.8 that returns a JSHandle. It returns when the expression returns a truthy value, and returns that value.

Frame.waitForSelector() strict option

Frame.waitForSelector() has a strict option available since v1.14 that requires the selector to match exactly one element.

Frame.type() - noWaitAfter parameter removed

The noWaitAfter option for Frame.type() was removed. It was available until v1.8.

Frame.type() strict option

Frame.type() has a strict option available since v1.14. When strict mode is enabled, the locator must match exactly one element.

Frame.type() timeout option

Frame.type() has a timeout option that specifies how long to wait for the action to complete, measured in milliseconds. Available since v1.8.

Frame.type() signal option

Frame.type() has a signal option that accepts an AbortSignal for cancellation.

Frame.uncheck() - async method

Frame.uncheck() is an async method available since v1.8 that unchecks an element matching the given selector. This method is discouraged in favor of using Locator.uncheck().

Frame.uncheck() steps

Frame.uncheck() performs the following steps: (1) Find an element matching the selector; if none exists, wait until a matching element is attached to the DOM. (2) Ensure the matched element is a checkbox or radio input; throw if not. If already unchecked, return immediately. (3) Wait for actionability checks on the matched element unless force option is set; retry the whole action if the element is detached during checks. (4) Scroll the element into view if needed. (5) Use Page.mouse to click in the center of the element. (6) Ensure the element is now unchecked; throw if not.

Frame.uncheck() selector parameter

Frame.uncheck() takes a selector parameter that is a string used to find the element to uncheck. Available since v1.8.

Frame.uncheck() force option

Frame.uncheck() has a force option that, when set, skips actionability checks. Available since v1.8.

Frame.uncheck() scroll option

Frame.uncheck() has a scroll option available since v1.62 that controls whether the element is scrolled into view before unchecking.

Frame.uncheck() noWaitAfter parameter removed

The noWaitAfter option for Frame.uncheck() was removed. It was available until v1.8.

Frame.uncheck() position option

Frame.uncheck() has a position option available since v1.11 that specifies a point on the element to click.

Frame.uncheck() strict option

Frame.uncheck() has a strict option available since v1.14 that requires the selector to match exactly one element.

Frame.uncheck() timeout option

Frame.uncheck() has a timeout option available since v1.8 that specifies how long to wait before throwing a TimeoutError. Passing zero disables the timeout.

Frame.uncheck() signal option

Frame.uncheck() has a signal option that accepts an AbortSignal for cancellation.

Frame.uncheck() trial option

Frame.uncheck() has a trial option available since v1.11 that performs a trial run without actually performing the action.

Frame.url() - returns string

Frame.url() is a method available since v1.8 that returns a string representing the frame's URL.

Frame.waitForFunction() polling option

Frame.waitForFunction() has a polling option available since v1.8 that controls how often the expression is evaluated. Different implementations exist for JavaScript/Python and C#/Java.

Frame.waitForFunction() timeout option

Frame.waitForFunction() has a timeout option available since v1.8 that specifies how long to wait for the expression to return a truthy value before throwing a TimeoutError.

Frame.waitForFunction() example - observe viewport size change

const { firefox } = require('playwright'); (async () => { const browser = await firefox.launch(); const page = await browser.newPage(); const watchDog = page.mainFrame().waitForFunction('window.innerWidth < 100'); await page.setViewportSize({ width: 50, height: 50 }); await watchDog; await browser.close(); })(); This example demonstrates using Frame.waitForFunction() to observe a viewport size change.

Frame.waitForFunction() example - pass argument to predicate

const selector = '.foo'; await frame.waitForFunction(selector => !!document.querySelector(selector), selector); This example demonstrates passing an argument to the predicate of Frame.waitForFunction().

Frame.waitForLoadState() - async method

Frame.waitForLoadState() is an async method available since v1.8 that waits for the frame to reach a required load state. It defaults to 'load'. The navigation must have been committed when this method is called. If the current document has already reached the required state, it resolves immediately.

Frame.waitForLoadState() state parameter

Frame.waitForLoadState() has a state parameter that specifies which load state to wait for. Available since v1.8.

Frame.waitForLoadState() timeout option

Frame.waitForLoadState() has a timeout option available since v1.8 that specifies how long to wait for the load state to be reached before throwing a TimeoutError.

Frame.waitForLoadState() signal option

Frame.waitForLoadState() has a signal option that accepts an AbortSignal for cancellation.

Frame.waitForNavigation() - returns Response or null

Frame.waitForNavigation() is an async method available since v1.8 that returns null or a Response object. It is deprecated in favor of Frame.waitForURL(). It waits for the frame navigation and returns the main resource response. In case of multiple redirects, it resolves with the response of the last redirect. In case of navigation to a different anchor or navigation due to History API usage, it resolves with null.

Frame.waitForNavigation() - Python variant returns EventContextManager

In Python, Frame.waitForNavigation() returns an EventContextManager<Response> object. The method is available since v1.8.

Frame.waitForNavigation() action parameter

Frame.waitForNavigation() has an action parameter available since v1.12 for C# that specifies a callback action to perform that will trigger the navigation.

Frame.waitForNavigation() url option

Frame.waitForNavigation() has a url option available since v1.8 that filters which navigation events to wait for based on the URL pattern.

Frame.waitForNavigation() timeout option

Frame.waitForNavigation() has a timeout option available since v1.8 that specifies how long to wait for navigation before throwing a TimeoutError.

Frame.waitForNavigation() callback parameter

Frame.waitForNavigation() has a callback parameter available since v1.9 for Java that specifies a callback to execute that will trigger the navigation.

Frame.waitForSelector() - returns ElementHandle or null

Frame.waitForSelector() is an async method available since v1.8 that returns an ElementHandle or null. It returns when the element specified by selector satisfies the state option. Returns null if waiting for 'hidden' or 'detached'. This method is discouraged in favor of using Locator.waitFor() or web assertions.

Frame.waitForSelector() selector parameter

Frame.waitForSelector() takes a selector parameter that is a CSS selector string used to find the element. Available since v1.8.

Frame.waitForSelector() state option

Frame.waitForSelector() has a state option available since v1.8 that specifies whether to wait for the element to appear/disappear from the DOM or become visible/hidden.

Frame.waitForSelector() timeout option

Frame.waitForSelector() has a timeout option available since v1.8 that specifies how long to wait before throwing a TimeoutError if the selector does not satisfy the condition.

Frame.waitForTimeout() - discouraged method

Frame.waitForTimeout() is an async method available since v1.8 that waits for the given timeout in milliseconds. This method is discouraged because tests that wait for time are inherently flaky. It should only be used for debugging.

Frame.waitForTimeout() timeout parameter

Frame.waitForTimeout() takes a timeout parameter of type float that specifies the number of milliseconds to wait.

Frame.waitForURL() - async method

Frame.waitForURL() is an async method available since v1.11 that waits for the frame to navigate to the given URL.

Frame.waitForURL() url parameter

Frame.waitForURL() takes a url parameter that specifies the URL pattern to wait for. Available since v1.11.

Frame.waitForURL() timeout option

Frame.waitForURL() has a timeout option available since v1.11 that specifies how long to wait before throwing a TimeoutError if the URL is not reached.

Frame.waitForURL() signal option

Frame.waitForURL() has a signal option that accepts an AbortSignal for cancellation.

Frame.waitForURL() waitUntil option

Frame.waitForURL() has a waitUntil option available since v1.11 that specifies when the navigation is considered complete.

Frame.waitForURL() example

await frame.click('a.delayed-navigation'); // Clicking the link will indirectly cause a navigation await frame.waitForURL('**/target.html'); This example demonstrates using Frame.waitForURL() to wait for navigation to a specific URL after clicking a link.

Give your agent this brain