Skip to content

0.22

Choose a tag to compare

@route route released this 01 Dec 12:43
· 10 commits to main since this release

Added

  • network.clear_cache clears the browser's HTTP cache, network.clear_traffic the collected traffic [#749]
  • :ssl_context for connecting to the browser at an https :url or a wss :ws_url with your own TLS settings [#742]
  • new_window: for create_target and create_page of a context and of the browser opens a window instead of a tab
  • close_target of a context and of the browser closes a target and removes it from the context at once, so
    targets and pages stop listing it right away instead of when Chrome reports it destroyed, as after page.close
  • browser.on_page { |page| } calls the block with every new page, popups included, before Ferrum returns it, so the
    page can be set up before anything runs on it
  • The gem ships its RBS signatures from sig/, so type checkers pick them up without local stubs [#731]
  • Network::Request#match?, #initial_priority and #referrer_policy, and Network::AuthRequest#url_fragment and
    #body, as all request classes now share RequestParams [#743]
  • mouse.wheel(delta_x:, delta_y:) turns the mouse wheel at the pointer, firing a wheel event and scrolling the
    element under it, unlike scroll_by [#744]
  • RemoteObject#evaluate, #evaluate_handle and #execute run JavaScript with this bound to the handle, as on
    Node [#746]
  • Network::Response#from_disk_cache? and #from_service_worker? tell whether a response came from the disk cache or
    a service worker [#751]
  • browser.disconnect closes the connection and leaves the browser running, so close, disconnect and
    process.stop make up a custom shutdown. quit still stops a browser disconnected this way [#750]
  • browser.shutdown asks the browser to exit, lets a launched one do so before killing it, and also shuts down a
    remote browser, unlike quit. process.stop(grace:) waits that long before signaling [#750]
  • context.downloads lists and awaits the downloads of every page in the context [#753]

Changed

  • evaluate awaits a returned promise in the same CDP call, so an object result crosses the socket once instead of
    twice, and an awaited script takes one call
  • A command cut off by a navigation, such as a script awaiting a promise, raises
    Ferrum::ExecutionContextDestroyedError instead of Ferrum::NodeNotFoundError, or a plain Ferrum::BrowserError in
    an iframe, as no node is involved. It isn't retried
  • A Node or RemoteObject argument from a previous page or another isolated world raises
    Ferrum::ForeignObjectError instead of Ferrum::NodeNotFoundError
  • downloads.files and await_download return Ferrum::Download objects instead of event hashes, with path
    where Chrome saved the file, state, completed?, suggested_filename and to_h for the raw params [#751]
  • window_bounds returns the shape window_bounds= takes, symbol keys and window_state:, instead of CDP's string
    keys and "windowState" [#751]
  • A wss:// connection to the browser verifies its certificate and host name and sends SNI, as the https
    /json/version request already did. A self-signed browser needs :ssl_context, see the option [#742]
  • User-Agent and Accept-Language set through headers are only sent with requests, they no longer change what
    navigator reports. Use network.emulate(user_agent:, accept_language:) to override both
  • Request interception takes one step: the first on(:request) or on(:auth) turns it on, network.intercept only
    narrows what's paused, and continues requests even before any callback is added. authorize takes an optional
    block [#745]
  • A pattern given to intercept narrows authorize, blacklist= and whitelist= too, they no longer reset it to
    *. Auth challenges and listed URLs outside the pattern aren't handled, widen it and filter with match? [#745]
  • An unknown mouse button, cookies.remove without :domain or :url, a relative go_to without :base_url and a
    relative :save_path raise ArgumentError instead of RuntimeError or Ferrum::Error. A failed screencast and
    debug_url raise Ferrum::Error. Errors that had no message or a misleading one say what's missing now [#557]
  • set_behavior moved from page.downloads to context.downloads and browser.downloads, as Chrome sets it for the
    whole context. browser.downloads is the default context's, page.downloads lists only the page's downloads [#753]
  • set_behavior takes :allow_and_name instead of :allowAndName, and needs save_path: only for :allow and
    :allow_and_name [#753]

Deprecated

  • :extensions, browser.add_extension and browser.extensions, will be removed in 1.0. Use :init_scripts,
    browser.add_init_script and browser.init_scripts
  • network.clear, will be removed in 1.0. Use network.clear_traffic or network.clear_cache [#749]
  • browser.reset, will be removed in 1.0. Use browser.contexts.reset [#748]

Fixed

  • evaluate of a script that starts a navigation and returns an object raised NoExecutionContextError, it returns
    the object now
  • Objects and arrays returned by evaluate and execute are released in the page, they stayed alive until it
    navigated to another document
  • A JavaScript call or execution_id! on a frame, page or worker that went away, or on a browser that died, while it
    had no execution context raises NoExecutionContextError at once, it waited out the whole timeout
  • keyboard.type and node.type type \n in a string as Enter, it was dropped
  • A failed Browser.new interrupted while it cleans up, e.g. by Timeout.timeout, closes the socket, stops its
    threads and the browser process instead of leaking them [#738]
  • A message from Chrome over :ws_max_receive_size raises DeadBrowserError that names the limit [#739]
  • browser.quit and restart interrupted while closing the connection to a hung browser, e.g. by Timeout.timeout,
    still stop the browser process [#740]
  • authorize without a block no longer warns NoMethodError on every request [#745]
  • A page or worker closed outside Ferrum, e.g. by window.close(), drops its event callbacks instead of keeping them
    for the rest of the browser's life [#750]
  • :process_timeout bounds the TLS handshake of a wss:// connection too, a host that accepts the connection and
    never answers raises ConnectTimeoutError instead of hanging [#741]
  • Downloads are tracked without :save_path, and a page sees its own when another page set the behavior. A new or
    closed page no longer resets it, and a popup's download shows up on the page that opened it [#753]

Removed

  • page.close_connection and worker.close_connection, a page's events stop once Chrome detaches it [#750]
  • Network::AUTHORIZE_BLOCK_MISSING, authorize no longer needs a block [#745]
  • Target#page=, a private API Cuprite no longer needs, build pages with create_page and set them up with
    on_page
  • Browser::Options::BASE_URL_SCHEMA, use BASE_URL_SCHEMES
  • target.window? and windows of a context and of the browser, use target.opener_id, await_page { ... } or
    pages(&:opener_id)
  • :js_errors, uncaught exceptions are in page.console with source: :exception, and page.on(:console) yields them
  • :pending_connection_errors and PendingConnectionsError, use go_to!, it raises NavigationTimeoutError
  • current_url and current_title of pages and frames, use url and title, or frame.page.url for the top window
    from a frame
  • cookies.all, use to_a, or map(&:name) for the names
  • flatten: false, every page shares the browser's websocket connection
  • FERRUM_DEBUG, use FERRUM_LOG=*
  • :protocol_timeout, browser.protocol_timeout, browser.protocol_timeout= and FERRUM_PROTOCOL_TIMEOUT, they were
    ignored, :timeout bounds everything else
  • wait: of click, mouse.up and mouse.down, use navigation_wait:. FERRUM_CLICK_WAIT and FERRUM_GOTO_WAIT,
    use FERRUM_NAVIGATION_WAIT
  • mode: and keys: of node.click, use button: :right or count: 2, and modifiers:
  • Positional mouse.scroll_by(x, y) and scroll_to(x, y), pass x: and y:
  • accessibility.enable and disable, use accessibility.enabled = true/false
  • goto, go, reload and reload!, use go_to, refresh and refresh!
  • frame.set_content, use content=
  • node.scroll_into_view, node.axnode and node[name], use scroll, ax_node and property(name)
  • contexts.each { |id, context| }, each yields the context, use context.id for the id
  • request_id of intercepted and auth requests, post_data of requests, and timestamp and monotonic_time of
    Network::Error, use id, body and time
  • disable_javascript, bypass_csp(enabled:), network.cache(disable:), offline_mode and
    emulate_network_conditions, use javascript = false, bypass_csp =, cache =, offline = true and throttle
  • body, use html. type and type? of Network::Request and type of Network::Response, use resource_type
    and resource_type?
  • Ferrum::NotImplementedError, nothing raises it since node.hover works
  • Passing a Hash with an "objectId" key to evaluate as a remote object, it is passed as a plain Hash now. Pass the
    Ferrum::RemoteObject from evaluate_handle
  • node.find_position, use pinpoint, its offsets are measured from the center unless position: :top
  • wait_for_navigation, wait_for_navigation!, wait_for_reload, wait_for_selector, network.wait_for_idle,
    wait_for_idle!, downloads.wait and node.wait_for_stop_moving, use await_navigation, wait_css, wait_xpath,
    wait_idle, page.await_download and wait_still. Positional network.idle?(n), pass connections: