You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
page.javascript = true/false and javascript? turn the page's scripts on and off, there was no way back on
network.offline = true/false takes the page offline and back online, network.throttle(latency:, download:, upload:)
slows it down. Each replaces the other's conditions, Chrome keeps one set of them
page.bypass_csp = true/false and network.cache = true/false
Ferrum::Deadline.within(seconds) { ... } bounds every call the block makes with one budget, page.go_to, cookies
and evaluate included. go_to raises NavigationTimeoutError once it runs out
timeout: on go_to, refresh, back, forward, click and await_navigation bounds the whole call with a single Ferrum::Deadline
context.target(id) returns the context's target with that id
timeout: on keyboard.type, node.type and mouse.move bounds all the keys or steps together, the page timeout
by default, raise it for a long text
context.await_page { ... }, and browser.await_page for the default context, runs the block and
returns the page it opens, in a tab or a window, or nil if none opens in time. await_page! raises Ferrum::TimeoutError instead. Pass opener: to only get the pages opened by one page
pages of a context and of the browser takes a block that selects targets, e.g. pages(&:opener_id) for
the pages opened by another page
go_to(url, referrer:) sets the referrer of that navigation only, the page's other requests don't carry it
cookies.set accepts http_only: and same_site: next to httponly: and samesite:, like the cookie's readers
cookies[name, domain:, path:] picks one of the cookies sharing a name
context.cookies with every cookie in the context whatever its domain, browser.cookies is the default context's
network.emulate(user_agent:, accept_language:, platform:, metadata:) overrides what the page reports in the request
headers and in navigator, platform had no way to be set before, and metadata keeps the client hints Chrome
otherwise stops sending once the user agent is overridden
go_to!, refresh!, back! and forward! raise NavigationTimeoutError, a TimeoutError naming the requests
still pending, when the page doesn't load in time
browser.off, window_bounds, window_bounds=, tracing, activate and document_size reach the page like the
rest of its methods
Waits share two verbs: await_* runs a block and waits for the event it triggers, wait_* polls a check. page.await_navigation { }, context.await_page { } and page.await_download { } return the navigation's result,
the page or the download. wait_css, wait_xpath, network.wait_idle, node.wait_still and page.wait_until { }
return what they waited for. Every one returns nil on timeout and has a ! version that raises TimeoutError
node.hover moves the mouse over the node, it raised NotImplementedError
node.pinpoint(x:, y:, position:) returns the point a click on the node lands on, x and y are an offset from
the center or, with position: :top, from the top-left corner. A single offset applies, and so does the offset of a
node without a box
Changed
Commands without a result return nil instead of true, self or Chrome's raw response: set_viewport, resize, stop, close, activate, execute, remove_script_on_new_document, dialog.accept/dismiss, network.intercept, clear and emulate, headers.add/set/clear, cookies.set/remove/clear/load, downloads.set_behavior, console.clear, browser.close/reset, context.dispose, contexts.dispose and worker.close. node.remove, select_file and execute return the node, like the other node commands
node.click(offset:) and hover(offset:) measure x and y from the center by default, pass position: :top for
the top-left corner
browser.contexts.each and the Enumerable methods yield contexts instead of [id, context] pairs
refresh, back and forward return nil when the page doesn't load in time instead of raising, use refresh!, back! and forward! to raise
network.idle? takes connections: as a keyword
client.command needs a timeout: and has no async: true, use client.notify to send without waiting, and browser.command defaults to the browser's timeout
Internal commands have a fixed 5 second timeout and the connection is closed once a write to the browser stalls for
30 seconds, :protocol_timeout no longer sets either
Creating pages and contexts follows timeout
wait: of click, mouse.up and mouse.down is renamed to navigation_wait:, false skips the wait
The waits after a click and after go_to share one default, Page::NAVIGATION_WAIT, set by FERRUM_NAVIGATION_WAIT
page.command doesn't take wait: anymore, wrap it in page.await_navigation to wait for a navigation it starts.
Passing wait: or async: to a command raises ArgumentError, they would be sent to the browser as parameters
page.event is page.idle and holds a Ferrum::Concurrency::Cell, not a Concurrent::Event
browser.targets and context.targets return a copy of the hash, it doesn't follow the targets that come and go
go_to, refresh and the script methods no longer restart the timeout for each step, one timeout covers the whole call
click, mouse.move, keyboard.type, back, forward, wait_css and node scripts share one timeout across the
commands they send, they restarted it for each
page.on(:request), on(:auth) and on(:dialog) callbacks form a chain: they run in order and the rest are skipped
once one continues, responds to, aborts, accepts or dismisses, and an unhandled request is continued. They receive
only the object, not index and total, use handled? to check whether a previous callback took it. A callback
that holds a request to answer later gets it continued, and one registered after the handler no longer sees it
page.cookies is the cookies the page sees, the ones sent to its URL and its frames' URLs, or each(urls:). It
returned every cookie in the context, use browser.cookies or browser.contexts[page.context_id].cookies for that. set and remove default to the page's host, clear keeps other domains, store/load are on the context only
NoSuchPageError is a NoSuchTargetError now, so rescuing NoSuchTargetError covers a target Chrome no longer
knows, like a closed page, as well as one Ferrum doesn't track
Every script runs the new way: keyword arguments are named parameters, promises and thenables are awaited, all
statements run and the last one's value is returned, and Node#evaluate returns nodes and dates, see upgrading [#673]
on with a raw CDP event yields only the params, not the callback's index and the total number of callbacks
node.click takes button:, count: and modifiers: like mouse.click, and holds the keys of keyboard.hold when
no modifiers: are given. The mouse methods take modifiers: as key names as well as a bitfield
mouse.scroll_by and scroll_to take x: and y:, an omitted one doesn't scroll along its axis
keyboard.modifiers and held_modifiers are internal now, pass modifiers: as key names
Deprecated
target.window?, will be removed in 0.22. Use target.opener_id, it is set for a target another one opened
windows of a context and of the browser, will be removed in 0.22. Use await_page { ... } for the page a click
opens, or pages(&:opener_id) for all of them
cookies.all, will be removed in 0.22. Keyed by name, it kept one of the cookies sharing a name, use to_a, or map(&:name) for the names
wait_for_navigation and wait_for_navigation!, will be removed in 0.22. Use await_navigation(watch:)
wait_for_reload, will be removed in 0.22. Use await_navigation { ... } around the code that reloads the page
wait_for_selector, will be removed in 0.22. Use wait_css or wait_xpath
network.wait_for_idle and wait_for_idle!, will be removed in 0.22. Use wait_idle, duration: is interval:
downloads.wait, will be removed in 0.22. Use page.await_download { ... }
node.wait_for_stop_moving, will be removed in 0.22. Use wait_still
Passing connections to network.idle? positionally, will be removed in 0.22. Pass connections:
current_url and current_title on pages and frames, will be removed in 0.22. Use url and title, or frame.page.url for the top window from a frame, frame.url is the frame's own
:js_errors, will be removed in 0.22. Uncaught exceptions are in page.console with source: :exception, use it or page.on(:console) instead
:pending_connection_errors and PendingConnectionsError, will be removed in 0.22. Use go_to! instead
User-Agent and Accept-Language set through headers changing what navigator reports, will stop in 0.22, where
they are only sent with requests. Use network.emulate(user_agent:, accept_language:) to override both
flatten: false, the option will be removed in 0.22 and every page will share the browser's websocket connection
FERRUM_DEBUG, will be removed in 0.22. Use FERRUM_LOG=* instead
:protocol_timeout, browser.protocol_timeout, browser.protocol_timeout= and FERRUM_PROTOCOL_TIMEOUT, will be
removed in 0.22. They are ignored and warn, :timeout bounds everything else
wait: of click, mouse.up and mouse.down, will be removed in 0.22. Use navigation_wait: instead
FERRUM_CLICK_WAIT and FERRUM_GOTO_WAIT, will be removed in 0.22. Use FERRUM_NAVIGATION_WAIT instead
goto, go, reload and reload!, will be removed in 0.22. Use go_to, refresh and refresh!
frame.set_content, will be removed in 0.22. Use content=
node.scroll_into_view, will be removed in 0.22. Use node.scroll
node.axnode, will be removed in 0.22. Use node.ax_node
node[name], will be removed in 0.22. Use node.property(name)
contexts.each { |id, context| }, will be removed in 0.22. each yields the context
request_id of intercepted and auth requests, will be removed in 0.22. Use id, like Request#id
post_data of requests, will be removed in 0.22. Use body
disable_javascript, bypass_csp(enabled:), network.cache(disable:), offline_mode and emulate_network_conditions, will be removed in 0.22. Use javascript = false, bypass_csp =, cache =, offline = true and throttle
timestamp and monotonic_time of Network::Error, will be removed in 0.22. Use time, which is now set for every
failure, not only the ones the browser logs a message for
mode: and keys: of node.click, will be removed in 0.22. Use button: :right or count: 2, and modifiers:
Positional mouse.scroll_by(x, y) and scroll_to(x, y), will be removed in 0.22. Pass x: and y:
accessibility.enable and disable, will be removed in 0.22. Use accessibility.enabled = true/false
body, will be removed in 0.22. Use html, it always returned the whole document
type and type? of Network::Request and type of Network::Response, will be removed in 0.22. Use resource_type and resource_type?, like the intercepted requests
Passing a Hash with an "objectId" key to evaluate as a remote object, will be removed in 0.22. Pass the Ferrum::RemoteObject from evaluate_handle
node.find_position, will be removed in 0.22. Use pinpoint, its offsets are measured from the center unless position: :top
Fixed
Network::Request#time keeps the fraction of a second, it was truncated to whole seconds
A Browser.new that failed or was interrupted while connecting left its connection and threads open, it closes them now
An unreachable url or ws_url host blocked Browser.new for the OS connect timeout, it raises Ferrum::ConnectTimeoutError, a TimeoutError, after process_timeout now
back on the first history entry reloaded the page, it returns nil now
A headful browser with xvfb: true sometimes started before Xvfb was ready and exited at once with ProcessTimeoutError, Ferrum waits for the display now
tracing.record timed out when page.on("Tracing.tracingComplete") was subscribed before its first call
page.command(method, wait:) ran a subclass override of command, like Cuprite's, twice
evaluate of a result nested about 100 levels deep raised an opaque BrowserError about Chrome's CBOR stack limit,
it raises ResultTooDeepError now, a BrowserError that says to return less or use evaluate_handle
worker.close never closed a dedicated worker, Chrome refuses to close it from outside, it closes itself now
page.on(:request, &:continue) never continued the request, it called continue(index, total) and the error was
dropped. Symbol procs and lambdas taking one argument get only the object now, for :request, :response, :auth
and :dialog
AuthRequest#abort raised BrowserError and left the page hanging, it cancels the auth challenge now
InterceptedRequest#navigation_request? and AuthRequest#navigation_request? always returned nil, they are true
for document requests now
evaluate raised NoMethodError when a node inside a Map or Set was also referenced elsewhere in the result
go_to kept sending a Referer after headers.clear or headers.set had removed it
headers.clear kept sending the old headers until the next add or set, and kept the user agent and language they
set. Now it clears them in Chrome right away
headers.add and headers.set reset a user agent or language set with network.emulate, and made Chrome stop
sending client hints, even for headers like X-Trace. They touch the user agent and language only when given one
pdf(path:) returned true while screenshot(path:) and mhtml(path:) return the number of bytes written, now it
returns the byte count too
mouse.scroll_by and scroll_to animated on a page with scroll-behavior: smooth in a Chrome without --disable-smooth-scrolling, so the position was mid-scroll when they returned. They scroll instantly now
at_css, css, at_xpath and xpath on a node inside an iframe raised NodeNotFoundError, now they search the
node's own frame
Node#moving? returned true for a node that wasn't moving and false for one that was. Its default delay is now
50ms instead of 10ms, which missed a slowly moving node, set it with FERRUM_NODE_MOVING_CHECK
Node#click and #find_position on a CSS-transformed node whose content quads can't be computed aimed by its
untransformed size and could miss it, now they aim at the center of its bounding rect. An SVG node raised JSON::GeneratorError there [#695]
Removed
#evaluate_async, #evaluate_func and #evaluate_on, use #evaluate and Node#evaluate, and page.await_navigation!(watch:) { } for evaluate_on's wait: [#673]
permanent: of headers.add, it only kept a Referer off the requests after the navigation, pass referrer: to go_to instead. headers.add("X-Trace" => "1") works without braces now, it raised ArgumentError
page.referrer and page.referrer=, pass referrer: to go_to instead
Mouse::CLICK_WAIT and Page::GOTO_WAIT, use Page::NAVIGATION_WAIT
Browser::Options::Base, Chrome is the only browser, Browser::Options::Chrome has everything it had
Ferrum::ServerError, nothing raised it
:browser_name, it only switched between Chrome-named defaults and raised NotImplementedError for anything else, set :browser_path to run Opera or Edge
cookie.sameparty? and same_party?, Chrome dropped SameParty cookies and they always returned nil