Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
apply heredoc for JS expression in Frame::DOM#wait_for_selector for c…
…onsistency
  • Loading branch information
Mifrill committed Feb 1, 2022
commit c1537141c5336cb2fbcd331531b0f01511568326
5 changes: 3 additions & 2 deletions lib/ferrum/frame/dom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def body
end

def wait_for_selector(css: nil, xpath: nil, timeout: 3000, interval: 100)
evaluate_func(%(
expr = <<~JS
function(selector, isXpath, timeout, interval) {
var attempts = 0;
var max = timeout / interval;
Expand All @@ -60,7 +60,8 @@ def wait_for_selector(css: nil, xpath: nil, timeout: 3000, interval: 100)
waitForSelector(resolve, reject);
});
}
), css || xpath, css.nil? && !xpath.nil?, timeout, interval, awaitPromise: true)
JS
evaluate_func(expr, css || xpath, css.nil? && !xpath.nil?, timeout, interval, awaitPromise: true)
end

def xpath(selector, within: nil)
Expand Down