From 1fae0cf4f7b417752f9de35d97998874dc2b8a1c Mon Sep 17 00:00:00 2001 From: Tim Tilberg Date: Wed, 11 Jan 2023 12:48:03 -0600 Subject: [PATCH] Use Promise in example for #evaluate_async Related to #234 --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b3c3754..c6ad4a2a 100644 --- a/README.md +++ b/README.md @@ -826,15 +826,19 @@ browser.evaluate("[window.scrollX, window.scrollY]") #### evaluate_async(expression, wait_time, \*args) -Evaluate asynchronous expression and return result +Evaluate an asynchronous expression and return result -* expression `String` should be valid JavaScript +* expression `String` should be valid JavaScript, and include the fulfill callback: `__f()` * wait_time How long we should wait for Promise to resolve or reject * args `Object` you can pass arguments, though it should be a valid `Node` or a simple value. ```ruby -browser.evaluate_async(%(arguments[0]({foo: "bar"})), 5) # => { "foo" => "bar" } +browser.evaluate_async < response.json()) + .then(body => __f(body)) +JS ``` #### execute(expression, \*args)