pub struct WaitForFunctionBuilder<'a> { /* private fields */ }Expand description
Builder for wait_for_function.
Implementations§
Source§impl<'a> WaitForFunctionBuilder<'a>
impl<'a> WaitForFunctionBuilder<'a>
Sourcepub async fn wait(self) -> Result<Option<JsHandle>, PageError>
pub async fn wait(self) -> Result<Option<JsHandle>, PageError>
Wait for the function to return a truthy value.
Returns Ok(Some(JsHandle)) when the result is a truthy object (DOM elements, objects, arrays).
Returns Ok(None) when the result is a truthy primitive (booleans, numbers, strings).
Primitive values have no object handle in the JavaScript runtime.
§Example
// Wait for a condition - primitives return None
let _handle = page.wait_for_function("() => document.body.innerText.includes('loaded')")
.wait()
.await?;
// handle is None because `.includes()` returns a boolean
// Wait for an element - objects return Some(JsHandle)
let handle = page.wait_for_function("() => document.querySelector('.ready')")
.wait()
.await?;
// handle is Some(JsHandle) referencing the elementTrait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for WaitForFunctionBuilder<'a>
impl<'a> !RefUnwindSafe for WaitForFunctionBuilder<'a>
impl<'a> Send for WaitForFunctionBuilder<'a>
impl<'a> Sync for WaitForFunctionBuilder<'a>
impl<'a> Unpin for WaitForFunctionBuilder<'a>
impl<'a> !UnwindSafe for WaitForFunctionBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more