Method: Playwright::Frame#wait_for_function

Defined in:
lib/playwright_api/frame.rb

#wait_for_function(expression, arg: nil, polling: nil, timeout: nil) ⇒ Object

Returns when the expression returns a truthy value, returns that value.

The [‘method: Frame.waitForFunction`] can be used to observe viewport size change:

“‘python sync from playwright.sync_api import sync_playwright

def run(playwright):

webkit = playwright.webkit
browser = webkit.launch()
page = browser.new_page()
page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
page.main_frame.wait_for_function("() => window.x > 0")
browser.close()

with sync_playwright() as playwright:

run(playwright)

“‘

To pass an argument to the predicate of frame.waitForFunction function:

“‘python sync selector = “.foo” frame.wait_for_function(“selector => !!document.querySelector(selector)”, selector) “`



707
708
709
# File 'lib/playwright_api/frame.rb', line 707

def wait_for_function(expression, arg: nil, polling: nil, timeout: nil)
  wrap_impl(@impl.wait_for_function(unwrap_impl(expression), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
end