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
cleanup: squash wrapperFunction with findElement function in wait_for…
…_selector
  • Loading branch information
Mifrill committed Feb 1, 2022
commit 6bd16efa47584d79b303785fd585f477369157a8
6 changes: 3 additions & 3 deletions lib/ferrum/frame/dom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ def wait_for_selector(selector, find_element_expression, timeout: 3000, interval
function(selector, findElementExpression, timeout, interval) {
var attempts = 0;
var max = timeout / interval;
var wrapperFunction = function(expression) {
var findElement = new Function(function(expression) {
return "{ return " + expression + " };";
}
}(findElementExpression))();
function waitForElement(resolve, reject) {
if (attempts > ((max < 1) ? 1 : max)) {
return reject(new Error("Not found element match the selector: " + selector));
}
var element = new Function(wrapperFunction(findElementExpression))()(selector);
var element = findElement(selector);
if (element !== null) {
return resolve(element);
}
Expand Down