Skip to content

Proper way to ensure that the page is loaded and ready to work with? #114

@Nakilon

Description

@Nakilon
require "ferrum"

br = Ferrum::Browser.new headless: false
br.goto "https://google.com/"
br.at_css("input[type=text]").focus.type "Ruby", :enter
sleep 2
br.at_css("body")

If I decrease sleep to 1 or remove the line at all it throws:

ferrum-0.9/lib/ferrum/browser/client.rb:46:in `command': Timed out waiting for response. It's possible that this happened because something took a very long time (for example a page load was slow). If so, setting the :timeout option to a higher value might help. (Ferrum::TimeoutError)

br.network.wait_for_idle hangs in the same way.
And this too:

t = Time.now
begin
  br.network.wait_for_idle timeout: 1
rescue Ferrum::TimeoutError
  raise if Time.now > t + 10
  retry
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions