diff --git a/.rubocop.yml b/.rubocop.yml index 70a352ca..b1da6234 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -51,7 +51,7 @@ Metrics/AbcSize: Max: 66 Metrics/ClassLength: - Max: 320 + Max: 300 Exclude: - spec/**/* diff --git a/CHANGELOG.md b/CHANGELOG.md index c1554268..7e8d9ccf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,51 @@ +## [Unreleased](https://github.com/rubycdp/ferrum/compare/v0.21.0...main) ## + +### Added + +### Changed +- `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 + +### Deprecated + +### Fixed + +### Removed +- `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:` + + ## [0.21.0](https://github.com/rubycdp/ferrum/compare/v0.20.2...v0.21.0) (November 24, 2026) ## ### Added diff --git a/docs/11-cookies.md b/docs/11-cookies.md index 7cfec2d1..8a4f7c3a 100644 --- a/docs/11-cookies.md +++ b/docs/11-cookies.md @@ -27,11 +27,6 @@ browser.cookies.to_a # => [#` - -Deprecated, will be removed in 0.22. Cookies keyed by name, so of the cookies sharing a name only one is kept. Use -`to_a`, or `map(&:name)` for the names. - #### \[\](name, domain: `String`, path: `String`) : `Cookie` | `nil` The first cookie with the given name. A name can be used by several cookies, on different domains or paths, `domain` @@ -119,7 +114,7 @@ browser.cookies.load #### each(urls: `Array`) : `Enumerator` The cookies sent to the page's URL and the URLs of its frames, or to the given URLs. Nothing before the page has -loaded a URL. `all` is deprecated here too. +loaded a URL. ```ruby page.cookies.map(&:name) # => ["session"] diff --git a/docs/12-headers.md b/docs/12-headers.md index cf5147f7..a7f301d1 100644 --- a/docs/12-headers.md +++ b/docs/12-headers.md @@ -16,11 +16,9 @@ Set given headers. Eventually clear all headers and set given ones. * headers `Hash` key-value pairs for example `"User-Agent" => "Browser"` -`User-Agent` and `Accept-Language` also change what `navigator` reports, through -[network.emulate](https://github.com/rubycdp/ferrum#network). Other headers leave it alone, and `set` and `clear` bring -back the browser's user agent or language once the header that changed it is gone. This is deprecated: from 0.22 the -two headers are only sent with requests, like any other, and `navigator` and the client hints stay as they are. Use -`network.emulate(user_agent:, accept_language:)` to override both the header and what the page reports. +`User-Agent` and `Accept-Language` are only sent with requests, like any other header, `navigator` and the client +hints stay as they are. Use [network.emulate(user_agent:, accept_language:)](https://github.com/rubycdp/ferrum#network) +to override both the header and what the page reports. #### add(headers) diff --git a/docs/15-frames.md b/docs/15-frames.md index edc0cb46..29fbf7a3 100644 --- a/docs/15-frames.md +++ b/docs/15-frames.md @@ -122,8 +122,7 @@ frame.main? # => false #### page : `Page` -The page the frame belongs to, use `frame.page.url` and `frame.page.title` for the top window. `current_url` and -`current_title` are deprecated and will be removed in 0.22. +The page the frame belongs to, use `frame.page.url` and `frame.page.title` for the top window. ```ruby page.go_to("https://www.w3schools.com/tags/tag_frame.asp") diff --git a/docs/2-customization.md b/docs/2-customization.md index 890371b2..6bc54b7f 100644 --- a/docs/2-customization.md +++ b/docs/2-customization.md @@ -15,9 +15,6 @@ Ferrum::Browser.new(options) * `:incognito` (Boolean) - Create an incognito profile for the browser startup window, `true` by default. * `:dockerize` (Boolean) - Provide CLI flags to the browser to run it in a container, `false` by default. * `:xvfb` (Boolean) - Run browser in a virtual framebuffer, `false` by default. - * `:flatten` (Boolean) - Use one websocket connection to the browser and all the pages in flatten mode, - `true` by default. When set to `false`, each page/target opens its own dedicated websocket connection instead - of sharing the browser's connection. Passing `false` is deprecated, the option will be removed in 0.22. * `:window_size` (Array) - The dimensions of the browser window in which to test, expressed as a 2-element array, e.g. [1024, 768]. Default: [1024, 768] * `:extensions` (Array[String | Hash]) - An array of paths to files or JS @@ -32,11 +29,6 @@ Ferrum::Browser.new(options) commands, like `evaluate` or `at_css`, waits for the browser's answer. A call that runs out raises `Ferrum::TimeoutError`. Pass `timeout:` to `go_to`, `refresh` or `await_navigation` to change it for one call, or wrap calls in `Ferrum::Deadline.within` to bound them together, see [Timeouts](#timeouts). - * `:js_errors` (Boolean) - Deprecated, will be removed in 0.22. When true, JavaScript errors get re-raised in - Ruby. Uncaught exceptions are in the [console](/docs/ferrum/javascript#console), use - `page.console.select { |m| m.source == :exception }` or `page.on(:console)` instead. - * `:pending_connection_errors` (Boolean) - Deprecated, will be removed in 0.22. Use `page.go_to!(url)` to raise - when the page doesn't load in time. * `:browser_path` (String) - Path to Chrome binary, or to an Opera or Edge one, you can also set ENV variable as `BROWSER_PATH=some/path/chrome bundle exec rspec`. * `:browser_options` (Hash) - Additional command line options, @@ -82,8 +74,7 @@ FERRUM_LOG=0 # nothing, even with :logger ``` Items with a dot are CDP method patterns, a leading `-` leaves things out and wins over the rest, and a response is -kept or dropped with the command it answers. Without `FERRUM_LOG`, `:logger` gets everything. `FERRUM_DEBUG` still -works as `FERRUM_LOG=*`, but is deprecated and will be removed in 0.22. +kept or dropped with the command it answers. Without `FERRUM_LOG`, `:logger` gets everything. `FERRUM_LOG_FORMAT` picks how CDP messages look. `json` writes each message as JSON alone, one per line and never colored, for tools such as `jq`. `annotated` puts the command id and method in front of each CDP message, one line diff --git a/docs/4-finders.md b/docs/4-finders.md index d635b3f9..d3340c5c 100644 --- a/docs/4-finders.md +++ b/docs/4-finders.md @@ -95,12 +95,9 @@ page.go_to("https://google.com/") page.title # => "Google" ``` -`current_url` and `current_title` are deprecated and will be removed in 0.22, use `url` and `title`. - #### html : `String` -Returns the HTML of the whole document, `` included. `body` is deprecated and will be removed in 0.22, it never -returned only ``. +Returns the HTML of the whole document, `` included. ```ruby page.go_to("https://google.com/") diff --git a/docs/7-network.md b/docs/7-network.md index 1428cae1..af3cfb2d 100644 --- a/docs/7-network.md +++ b/docs/7-network.md @@ -237,8 +237,6 @@ page.network.offline = false Overrides the user agent, the accept language, the platform and the client hints the page reports, in the request headers and in `navigator`. The options you don't pass keep their previous values, `nil` brings one back to the browser's default. -Setting `User-Agent` or `Accept-Language` with [headers](https://github.com/rubycdp/ferrum#headers) goes through -here too, the last one set wins. That is deprecated and stops in 0.22. * options `Hash` * :user_agent `String` the `User-Agent` header and `navigator.userAgent` diff --git a/lib/ferrum/accessibility.rb b/lib/ferrum/accessibility.rb index 37a93d2c..30adf633 100644 --- a/lib/ferrum/accessibility.rb +++ b/lib/ferrum/accessibility.rb @@ -105,32 +105,6 @@ def enabled=(enabled) @page.command(enabled ? "Accessibility.enable" : "Accessibility.disable") end - # - # @deprecated Will be removed in Ferrum 0.22. Use `enabled = true`. - # - # @return [self] - # - # @raise [TimeoutError] - # - def enable - Utils::Deprecate.warn("accessibility.enable will be removed in Ferrum 0.22. Use enabled = true instead.", - user_code: true) - tap { self.enabled = true } - end - - # - # @deprecated Will be removed in Ferrum 0.22. Use `enabled = false`. - # - # @return [self] - # - # @raise [TimeoutError] - # - def disable - Utils::Deprecate.warn("accessibility.disable will be removed in Ferrum 0.22. Use enabled = false instead.", - user_code: true) - tap { self.enabled = false } - end - private def build(nodes) diff --git a/lib/ferrum/browser.rb b/lib/ferrum/browser.rb index 60689a5c..eace4322 100644 --- a/lib/ferrum/browser.rb +++ b/lib/ferrum/browser.rb @@ -27,30 +27,28 @@ class Browser extend Forwardable delegate %i[default_context] => :contexts - delegate %i[targets create_target page pages windows await_page await_page! workers service_workers + delegate %i[targets create_target page pages await_page await_page! workers service_workers attach_target cookies] => :default_context - delegate %i[go_to go_to! goto go back back! forward forward! refresh refresh! reload reload! stop + delegate %i[go_to go_to! back back! forward forward! refresh refresh! stop await_navigation await_navigation! await_download await_download! wait_until wait_until! - wait_for_reload wait_for_navigation wait_for_navigation! - at_css at_xpath css xpath wait_css wait_css! wait_xpath wait_xpath! wait_for_selector - current_url current_title url title - html body doctype content= + at_css at_xpath css xpath wait_css wait_css! wait_xpath wait_xpath! + url title html doctype content= headers network console accessibility downloads tracing mouse keyboard screenshot pdf mhtml viewport_size device_pixel_ratio document_size start_screencast stop_screencast frames frame_by main_frame evaluate evaluate_handle execute isolated_world - add_script_tag add_style_tag bypass_csp bypass_csp= + add_script_tag add_style_tag bypass_csp= evaluate_on_new_document remove_script_on_new_document on off position position= window_bounds window_bounds= activate playback_rate playback_rate= - disable_javascript javascript= javascript? set_viewport resize] => :page + javascript= javascript? set_viewport resize] => :page attr_reader :client, :process, :contexts, :options - delegate %i[timeout timeout= protocol_timeout protocol_timeout= base_url base_url= default_user_agent - default_user_agent= extensions add_extension] => :options + delegate %i[timeout timeout= base_url base_url= default_user_agent default_user_agent= extensions + add_extension] => :options # # Initializes the browser. @@ -70,11 +68,6 @@ class Browser # @option options [Boolean] :xvfb (false) # Run browser in a virtual framebuffer. # - # @option options [Boolean] :flatten (true) - # Use one websocket connection to the browser and all the pages in flatten mode. - # Passing `false` is deprecated, the option will be removed in Ferrum 0.22 - # and every page will share the browser's connection. - # # @option options [(Integer, Integer)] :window_size ([1024, 768]) # The dimensions of the browser window in which to test, expressed as a # 2-element array, e.g. `[1024, 768]`. @@ -98,16 +91,6 @@ class Browser # `FERRUM_DEFAULT_TIMEOUT` sets the default. Pass `timeout:` to `go_to`, `refresh` or `await_navigation` to # change it for one call, or wrap calls in {Deadline.within} to bound them together. # - # @option options [Boolean] :js_errors - # Deprecated, will be removed in Ferrum 0.22. When true, JavaScript - # errors get re-raised in Ruby. Uncaught exceptions are in the console, - # use `page.console.select { |m| m.source == :exception }` or - # `page.on(:console)` instead. - # - # @option options [Boolean] :pending_connection_errors (false) - # Deprecated, will be removed in Ferrum 0.22. Makes `go_to` raise - # {PendingConnectionsError} on timeout, use `go_to!` instead. - # # @option options [String] :browser_path # Path to Chrome binary, you can also set ENV variable as # `BROWSER_PATH=some/path/chrome bundle exec rspec`. diff --git a/lib/ferrum/browser/options.rb b/lib/ferrum/browser/options.rb index cde5062d..9f5123d5 100644 --- a/lib/ferrum/browser/options.rb +++ b/lib/ferrum/browser/options.rb @@ -18,21 +18,11 @@ class Options DEFAULT_TIMEOUT = ENV.fetch("FERRUM_DEFAULT_TIMEOUT", 5).to_f PROCESS_TIMEOUT = ENV.fetch("FERRUM_PROCESS_TIMEOUT", 10).to_i - PROTOCOL_TIMEOUT_REMOVED = "is ignored and will be removed in Ferrum 0.22. Internal commands have a fixed " \ - "timeout, :timeout bounds everything else." - - if ENV.key?("FERRUM_DEBUG") - Utils::Deprecate.warn("FERRUM_DEBUG will be removed in Ferrum 0.22. Use FERRUM_LOG=* instead.") - end - if ENV.key?("FERRUM_PROTOCOL_TIMEOUT") - Utils::Deprecate.warn("FERRUM_PROTOCOL_TIMEOUT #{PROTOCOL_TIMEOUT_REMOVED}") - end - attr_reader :window_size, :logger, :log, :ws_max_receive_size, - :js_errors, :base_url, :slowmo, :pending_connection_errors, + :base_url, :slowmo, :url, :ws_url, :env, :process_timeout, :browser_path, :save_path, :proxy, :port, :host, :headless, :incognito, :dockerize, :browser_options, - :ignore_default_browser_options, :xvfb, :flatten, :extensions + :ignore_default_browser_options, :xvfb, :extensions attr_accessor :timeout, :default_user_agent def initialize(options = nil) @@ -41,21 +31,10 @@ def initialize(options = nil) @port = @options.fetch(:port, BROWSER_PORT) @host = @options.fetch(:host, BROWSER_HOST) @timeout = @options.fetch(:timeout, DEFAULT_TIMEOUT) - warn_protocol_timeout if @options.key?(:protocol_timeout) @window_size = @options.fetch(:window_size, WINDOW_SIZE) - @js_errors = fetch_deprecated( - :js_errors, - "Uncaught exceptions are in the console, use page.console.select { |m| m.source == :exception } " \ - "or page.on(:console)." - ) @headless = @options.fetch(:headless, true) @incognito = @options.fetch(:incognito, true) @dockerize = @options.fetch(:dockerize, false) - @flatten = @options.fetch(:flatten, true) - warn_flatten unless @flatten - @pending_connection_errors = fetch_deprecated( - :pending_connection_errors, "Use page.go_to!(url) to raise when the page doesn't load in time." - ) @process_timeout = @options.fetch(:process_timeout, PROCESS_TIMEOUT) @slowmo = @options[:slowmo].to_f @@ -77,29 +56,6 @@ def initialize(options = nil) @browser_options = @options.fetch(:browser_options, {}).freeze end - # - # Deprecated, will be removed in Ferrum 0.22. Internal commands have a fixed timeout. - # - # @return [Integer] - # {Client::PROTOCOL_TIMEOUT}. - # - def protocol_timeout - warn_protocol_timeout - Client::PROTOCOL_TIMEOUT - end - - # - # Deprecated, will be removed in Ferrum 0.22. The value is ignored. - # - # @param [Numeric] value - # - # @return [Numeric] - # - def protocol_timeout=(value) - warn_protocol_timeout - value - end - # # Sets the base URL relative navigations are resolved against. # @@ -168,30 +124,12 @@ def to_h private - def warn_protocol_timeout - Utils::Deprecate.warn(":protocol_timeout #{PROTOCOL_TIMEOUT_REMOVED}", user_code: true) - end - - def warn_flatten - Utils::Deprecate.warn( - "flatten: false will be removed in Ferrum 0.22. Every page will share the browser's websocket connection.", - user_code: true - ) - end - - def fetch_deprecated(name, instead) - return false unless @options.key?(name) - - Utils::Deprecate.warn(":#{name} will be removed in Ferrum 0.22. #{instead}", user_code: true) - @options[name] - end - def read_extension(extension) (extension.is_a?(Hash) && extension[:source]) || File.read(extension) end def parse_logger(logger) - value = ENV.fetch("FERRUM_LOG") { "*" if ENV.key?("FERRUM_DEBUG") } + value = ENV.fetch("FERRUM_LOG", nil) settings = value ? Log.parse(value) : {} logger ||= $stdout.tap { |s| s.sync = true } if value && settings return [logger, nil] unless logger && settings diff --git a/lib/ferrum/context.rb b/lib/ferrum/context.rb index 6b4a9444..027aca79 100644 --- a/lib/ferrum/context.rb +++ b/lib/ferrum/context.rb @@ -11,10 +11,6 @@ module Ferrum # of contexts and routes CDP target events to the right one. # class Context - POSITION = %i[first last].freeze - WINDOWS_DEPRECATED = "windows will be removed in Ferrum 0.22. Use await_page { ... } for the page a click " \ - "opens, or pages(&:opener_id) for all of them." - attr_reader :id def initialize(client, contexts, id, implicit: false) @@ -110,29 +106,6 @@ def service_workers @targets.values.select(&:service_worker?) end - # The pages of this context opened by another page. - # - # @deprecated Will be removed in Ferrum 0.22. Use {#await_page} for the page a click opens, or - # `pages(&:opener_id)` for all of them. - # - # @param [:first, :last, nil] pos - # - # @param [Integer] size - # - # @return [Array] - # - # @raise [ArgumentError] - # - # @raise [TimeoutError] - def windows(pos = nil, size = 1) - Utils::Deprecate.warn(WINDOWS_DEPRECATED, user_code: true) - raise ArgumentError if pos && !POSITION.include?(pos) - - windows = @targets.values.select(&:opener_id) - windows = windows.send(pos, size) if pos - windows.map(&:page) - end - # Runs the block and returns the page it opens, in a tab or a window, # e.g. through `window.open` or a link with `target="_blank"`. # diff --git a/lib/ferrum/contexts.rb b/lib/ferrum/contexts.rb index a91b5ed0..17dd002e 100644 --- a/lib/ferrum/contexts.rb +++ b/lib/ferrum/contexts.rb @@ -14,9 +14,6 @@ class Contexts ALLOWED_TARGET_TYPES = %w[page iframe worker shared_worker service_worker].freeze RECURSIVE_AUTO_ATTACH_TYPES = %w[page iframe worker shared_worker].freeze - EACH_PAIRS_DEPRECATED = "contexts.each { |id, context| } will be removed in Ferrum 0.22. It yields the context, " \ - "use context.id for the id." - include Enumerable # @api private @@ -50,8 +47,6 @@ def default_context end # Iterates over the contexts; returns an `Enumerator` if no block is given. - # A block taking two arguments still gets `[id, context]` pairs, which is - # deprecated and will be removed in Ferrum 0.22. # # @yieldparam [Context] context # @@ -59,12 +54,7 @@ def default_context def each(&block) return enum_for(__method__) unless block - if block.arity == 2 - Utils::Deprecate.warn(EACH_PAIRS_DEPRECATED, user_code: true) - @contexts.each(&block) - else - @contexts.each_value(&block) - end + @contexts.each_value(&block) self end diff --git a/lib/ferrum/cookies/collection.rb b/lib/ferrum/cookies/collection.rb index 1efda8ea..b9fe8714 100644 --- a/lib/ferrum/cookies/collection.rb +++ b/lib/ferrum/cookies/collection.rb @@ -9,36 +9,6 @@ class Cookies module Collection include Enumerable - # - # @deprecated Will be removed in Ferrum 0.22, it keeps one cookie per - # name. Use `to_a`, or `map(&:name)` for the names. - # - # Returns cookies hash. - # - # @param [Hash] options - # Passed to `each`. - # - # @return [Hash{String => Cookie}] - # - # @example - # page.cookies.all # => { - # # "NID" => #"NID", "value"=>"...", "domain"=>".google.com", "path"=>"/", - # # "expires"=>1583211046.575681, "size"=>178, "httpOnly"=>true, "secure"=>false, "session"=>false - # # }> - # # } - # - def all(**options) - Utils::Deprecate.warn( - "cookies.all will be removed in Ferrum 0.22, it keeps one cookie per name. " \ - "Use cookies.to_a, or cookies.map(&:name) for the names.", - user_code: true - ) - each(**options).to_h do |cookie| - [cookie.name, cookie] - end - end - # # Returns the first cookie with the given name, narrowed down by domain # and path when the name is used by more than one cookie. diff --git a/lib/ferrum/downloads.rb b/lib/ferrum/downloads.rb index f497b86a..022949d9 100644 --- a/lib/ferrum/downloads.rb +++ b/lib/ferrum/downloads.rb @@ -10,8 +10,6 @@ module Ferrum # class Downloads WAIT_TIMEOUT = 5 - WAIT_DEPRECATED = "downloads.wait will be removed in Ferrum 0.22. Use page.await_download { ... } around the " \ - "code that starts the download." VALID_BEHAVIOR = %i[deny allow allowAndName default].freeze def initialize(page) @@ -80,28 +78,6 @@ def await_download!(timeout: WAIT_TIMEOUT, &) await_download(timeout: timeout, &) || raise(TimeoutError) end - # - # Waits until the current download finishes. - # - # @deprecated Will be removed in Ferrum 0.22. Use {#await_download} around the code that starts the download. - # - # @param [Numeric, Deadline] timeout - # How long to wait in seconds. - # - # @yield - # Optional block that triggers the download, e.g. clicking a link. - # - # @return [void] - # - def wait(timeout = WAIT_TIMEOUT) - Utils::Deprecate.warn(WAIT_DEPRECATED, user_code: true) - deadline = Deadline.wrap(timeout) - generation = @idle.clear - yield if block_given? - @idle.wait(deadline) - @idle.set(true) if generation == @idle.generation - end - # # Sets the browser's download behavior and destination directory. # diff --git a/lib/ferrum/errors.rb b/lib/ferrum/errors.rb index bd9788c3..e188314a 100644 --- a/lib/ferrum/errors.rb +++ b/lib/ferrum/errors.rb @@ -7,8 +7,6 @@ class Error < StandardError; end class NoSuchTargetError < Error; end # Raised when Chrome reports that the referenced page no longer exists, a {NoSuchTargetError} for pages. class NoSuchPageError < NoSuchTargetError; end - # Raised when a requested feature isn't implemented for the current setup. - class NotImplementedError < Error; end # Raised when no browser binary can be found at the configured path. class BinaryNotFoundError < Error; end # Raised when a required file path option is empty. @@ -22,23 +20,6 @@ def initialize(url, message = nil) end end - # Raised when the request reached the server, but the page still has - # pending network connections that never settled. - # - # @deprecated Will be removed in Ferrum 0.22 with the `:pending_connection_errors` - # option. `go_to!` raises {NavigationTimeoutError}. - class PendingConnectionsError < StatusError - attr_reader :pendings - - def initialize(url, pendings = []) - @pendings = pendings - message = "Request to #{url} reached server, but there are still pending connections" - message += ": #{pendings.join(', ')}" unless @pendings.empty? - - super(url, message) - end - end - # Raised when waiting for a response from the browser times out. class TimeoutError < Error # The CDP method that didn't answer in time, `nil` when the wait wasn't for a command. diff --git a/lib/ferrum/frame.rb b/lib/ferrum/frame.rb index 985bfc48..a8e86cb3 100644 --- a/lib/ferrum/frame.rb +++ b/lib/ferrum/frame.rb @@ -202,18 +202,6 @@ def content=(html) @page.document_node_id end - # - # @deprecated Will be removed in Ferrum 0.22. Use {#content=}. - # - # @param [String] html - # - # @raise [TimeoutError] - # - def set_content(html) # rubocop:disable Naming/AccessorMethodName - Utils::Deprecate.warn("set_content will be removed in Ferrum 0.22. Use content= instead.", user_code: true) - self.content = html - end - # # Execution context id which is used by JS, each frame has it's own # context in which JS evaluates. Locks for a page timeout and raises diff --git a/lib/ferrum/frame/dom.rb b/lib/ferrum/frame/dom.rb index f7321d70..1c49225d 100644 --- a/lib/ferrum/frame/dom.rb +++ b/lib/ferrum/frame/dom.rb @@ -27,8 +27,6 @@ class Frame # module DOM WAIT_INTERVAL = 0.05 - WAIT_FOR_SELECTOR_DEPRECATED = "wait_for_selector will be removed in Ferrum 0.22. Use wait_css(selector) or " \ - "wait_xpath(selector) instead." SCRIPT_SRC_TAG = <<~JS function(url, type) { const script = document.createElement("script"); @@ -64,44 +62,6 @@ module DOM } JS - # - # @deprecated Will be removed in Ferrum 0.22. Use `page.url`, or - # `frame.page.url` from a frame. - # - # Returns current top window `location href`. - # - # @return [String] - # The window's current URL. - # - # @raise [TimeoutError] - # - def current_url - Utils::Deprecate.warn( - "#current_url will be removed in Ferrum 0.22. Use page.url, or frame.page.url from a frame, " \ - "frame.url is the frame's own URL." - ) - evaluate("window.top.location.href") - end - - # - # @deprecated Will be removed in Ferrum 0.22. Use `page.title`, or - # `frame.page.title` from a frame. - # - # Returns current top window title. - # - # @return [String] - # The window's current title. - # - # @raise [TimeoutError] - # - def current_title - Utils::Deprecate.warn( - "#current_title will be removed in Ferrum 0.22. Use page.title, or frame.page.title from a frame, " \ - "frame.title is the frame's own title." - ) - evaluate("window.top.document.title") - end - # # Returns current document's doctype declaration. # @@ -135,19 +95,6 @@ def html evaluate("document.documentElement?.outerHTML") || "" end - # - # @deprecated Will be removed in Ferrum 0.22. Use {#html}, it was never - # only ``. - # - # @return [String] - # - # @raise [TimeoutError] - # - def body - Utils::Deprecate.warn("body will be removed in Ferrum 0.22. Use html instead.", user_code: true) - html - end - # # Returns the element in which the window is embedded. # @@ -374,35 +321,6 @@ def wait_xpath!(selector, **options) wait_xpath(selector, **options) || raise(TimeoutError) end - # - # Finds a node by using a CSS path or XPath selector, retrying until - # it appears or `timeout` elapses. - # - # @deprecated Will be removed in Ferrum 0.22. Use {#wait_css} or {#wait_xpath}. - # - # @param [String, nil] css - # - # @param [String, nil] xpath - # - # @param [Node, nil] within - # - # @param [Numeric, Deadline] timeout - # - # @param [Float, Integer] interval - # - # @return [Node, nil] - # - # @raise [ArgumentError] - # If neither or both of `css`/`xpath` are given. - # - def wait_for_selector(css: nil, xpath: nil, within: nil, timeout: @page.timeout, interval: WAIT_INTERVAL) - Utils::Deprecate.warn(WAIT_FOR_SELECTOR_DEPRECATED, user_code: true) - raise ArgumentError, "pass either `css:` or `xpath:`" if (css && xpath) || !(css || xpath) - - options = { within: within, timeout: timeout, interval: interval } - css ? wait_css(css, **options) : wait_xpath(xpath, **options) - end - # # Adds a `