Skip to content
Open
Show file tree
Hide file tree
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
set default timeout 3 sec
  • Loading branch information
Mifrill committed Jan 15, 2022
commit cf74591384ffb8351befab380b1e07f00cf3f563
2 changes: 1 addition & 1 deletion lib/ferrum/frame/dom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def body
evaluate("document.documentElement.outerHTML")
end

def wait_for_selector(css: nil, xpath: nil, timeout: 5000, interval: 100)
def wait_for_selector(css: nil, xpath: nil, timeout: 3000, interval: 100)
evaluate_func(%(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be more consistent with the rest of the gem, would you mind changing this to use a JS heredoc? This is helpful because many editors support code highlighting in the language specified:

Original:
image

VS:

Subl:
image

Code:
image

I haven't tried the code out yet, but I'm looking forward to this feature!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it makes sense, will change, thanks!

function(selector, isXpath, timeout, interval) {
var attempts = 0;
Expand Down
6 changes: 6 additions & 0 deletions spec/browser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,12 @@ module Ferrum
expect(browser.wait_for_selector(xpath: "//div[@id='wait_for_hidden_selector']")).not_to be_nil
end

it "raises error when default timeout exceed" do
expect do
browser.wait_for_selector(css: "div#not_existed_element")
end.to raise_error(Ferrum::JavaScriptError, /Not found element match the selector/)
end

it "raises error when timeout exceed" do
expect do
browser.wait_for_selector(css: "div#wait_for_selector", timeout: 800)
Expand Down