class Playwright::Page

def wait_for_function(expression, arg: nil, polling: nil, timeout: nil)

```
page.wait_for_function("selector => !!document.querySelector(selector)", selector)
selector = ".foo"
```python sync

To pass an argument to the predicate of [`method: Page.waitForFunction`] function:

```
run(playwright)
with sync_playwright() as playwright:

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

from playwright.sync_api import sync_playwright, Playwright
```python sync

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

**Usage**

Returns when the `expression` returns a truthy value. It resolves to a JSHandle of the truthy value.
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