Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Promise in example for #evaluate_async #325

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<JS, 5
fetch("https://www.httpbin.org/json")
.then(response => response.json())
.then(body => __f(body))
JS
```

#### execute(expression, \*args)
Expand Down