diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ee899b..8cc6fc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ `Ferrum::JavaScriptError: node.getRootNode(...).elementFromPoint is not a function` [#359] - `Driver#reset!` and `Driver#quit` don't launch Chrome when no browser has started, so a failed launch doesn't launch again during teardown +- `scroll_to` with an element or a location waits for the scroll like `scroll_to(x, y)` and `scroll_by` already do, + instead of making Ferrum warn that the script returns a promise [#362] ### Removed - Methods deprecated in 0.20, see its Deprecated section for replacements diff --git a/lib/capybara/cuprite/node.rb b/lib/capybara/cuprite/node.rb index 9d1511e..1bb34f1 100644 --- a/lib/capybara/cuprite/node.rb +++ b/lib/capybara/cuprite/node.rb @@ -339,7 +339,7 @@ def scroll_element_to_location(element, location) else raise ArgumentError, "Invalid scroll_to location: #{location}" end - element.node.evaluate("this.scrollIntoView(#{scroll_opts})") + element.node.evaluate("await this.scrollIntoView(#{scroll_opts})") end def scroll_to_location(location) @@ -347,7 +347,7 @@ def scroll_to_location(location) bottom: "this.scrollHeight", center: "(this.scrollHeight - this.clientHeight) / 2" } - node.evaluate("this.scrollTo(0, #{height[location]})") + node.evaluate("await this.scrollTo(0, #{height[location]})") end def scroll_to_coords(x, y)