repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/lexer.rb | lib/gitsh/tab_completion/dsl/lexer.rb | require 'rltk/lexer'
module Gitsh
module TabCompletion
module DSL
class Lexer < RLTK::Lexer
WORD_CHARACTERS = /[^\s*+?|()#\$]/
rule(/\$opt/) { :OPT_VAR }
rule(/\$[a-z_]+/) { |t| [:VAR, t[1..-1]] }
rule(/[a-z_]+::/) { |t| [:MODIFIER, t[0..-3]] }
rule(/-[A-Za-z0-9]/... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/null_factory.rb | lib/gitsh/tab_completion/dsl/null_factory.rb | module Gitsh
module TabCompletion
module DSL
class NullFactory
def build(*_)
end
end
end
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/concatenation_factory.rb | lib/gitsh/tab_completion/dsl/concatenation_factory.rb | module Gitsh
module TabCompletion
module DSL
class ConcatenationFactory
attr_reader :parts
def initialize(parts)
@parts = parts
end
def build(start_state, options = {})
with_optional_end_state(options) do
parts.inject(start_state) do |state, ... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/dsl/variable_transition_factory.rb | lib/gitsh/tab_completion/dsl/variable_transition_factory.rb | require 'gitsh/tab_completion/automaton'
module Gitsh
module TabCompletion
module DSL
class VariableTransitionFactory
attr_reader :matcher
def initialize(matcher)
@matcher = matcher
end
def build(start_state, options = {})
end_state = options.fetch(:end... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/matchers/base_matcher.rb | lib/gitsh/tab_completion/matchers/base_matcher.rb | module Gitsh
module TabCompletion
module Matchers
class BaseMatcher
def match?(_)
true
end
def completions(token)
all_completions.select { |option| option.start_with?(token) }
end
def eql?(other)
self.class == other.class
end
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/matchers/tag_matcher.rb | lib/gitsh/tab_completion/matchers/tag_matcher.rb | require 'gitsh/tab_completion/matchers/base_matcher'
module Gitsh
module TabCompletion
module Matchers
class TagMatcher < BaseMatcher
def initialize(env)
@env = env
end
def name
'tag'
end
private
attr_reader :env
def all_comple... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/matchers/revision_matcher.rb | lib/gitsh/tab_completion/matchers/revision_matcher.rb | require 'gitsh/tab_completion/matchers/base_matcher'
module Gitsh
module TabCompletion
module Matchers
class RevisionMatcher < BaseMatcher
SEPARATORS = /(?:\.\.+|[:^~\\])/
def initialize(env)
@env = env
end
def name
'revision'
end
def c... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/matchers/remote_matcher.rb | lib/gitsh/tab_completion/matchers/remote_matcher.rb | require 'gitsh/tab_completion/matchers/base_matcher'
module Gitsh
module TabCompletion
module Matchers
class RemoteMatcher < BaseMatcher
def initialize(env)
@env = env
end
def name
'remote'
end
private
attr_reader :env
def all_... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/matchers/path_matcher.rb | lib/gitsh/tab_completion/matchers/path_matcher.rb | require 'gitsh/tab_completion/matchers/base_matcher'
module Gitsh
module TabCompletion
module Matchers
class PathMatcher < BaseMatcher
def initialize(_env)
end
def completions(token)
prefix = normalize_path(token)
paths(prefix).map { |option| option.sub(prefix, ... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/matchers/unknown_option_matcher.rb | lib/gitsh/tab_completion/matchers/unknown_option_matcher.rb | require 'gitsh/tab_completion/matchers/base_matcher'
module Gitsh
module TabCompletion
module Matchers
class UnknownOptionMatcher < BaseMatcher
def match?(word)
word =~ /\A--?[^-]/
end
def name
'opt'
end
end
end
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/matchers/text_matcher.rb | lib/gitsh/tab_completion/matchers/text_matcher.rb | require 'gitsh/tab_completion/matchers/base_matcher'
module Gitsh
module TabCompletion
module Matchers
class TextMatcher < BaseMatcher
attr_reader :word
def initialize(word)
@word = word
end
def match?(match_word)
word == match_word
end
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/matchers/anything_matcher.rb | lib/gitsh/tab_completion/matchers/anything_matcher.rb | require 'gitsh/tab_completion/matchers/base_matcher'
module Gitsh
module TabCompletion
module Matchers
class AnythingMatcher < BaseMatcher
def initialize(_env)
end
def name
'anything'
end
end
end
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/matchers/command_matcher.rb | lib/gitsh/tab_completion/matchers/command_matcher.rb | require 'gitsh/tab_completion/matchers/base_matcher'
require 'gitsh/commands/internal_command'
module Gitsh
module TabCompletion
module Matchers
class CommandMatcher < BaseMatcher
def initialize(env, internal_command = Commands::InternalCommand)
@env = env
@internal_command = in... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/tab_completion/matchers/branch_matcher.rb | lib/gitsh/tab_completion/matchers/branch_matcher.rb | require 'gitsh/tab_completion/matchers/base_matcher'
module Gitsh
module TabCompletion
module Matchers
class BranchMatcher < BaseMatcher
def initialize(env)
@env = env
end
def name
'branch'
end
private
attr_reader :env
def all_... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/lib/gitsh/lexer/character_class.rb | lib/gitsh/lexer/character_class.rb | require 'rltk'
module Gitsh
class Lexer < RLTK::Lexer
class CharacterClass
attr_reader :characters
def initialize(characters)
@characters = characters
end
def +(other)
self.class.new(characters + other.characters)
end
def to_regexp
Regexp.new("[#{Reg... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/page_spec.rb | spec/page_spec.rb | # frozen_string_literal: true
describe Ferrum::Page do
describe "#go_to" do
let(:port) { server.port }
context "with success response" do
it "works when DNS correct" do
expect { page.go_to("http://localhost:#{port}/") }.not_to raise_error
end
it "reports no open resources when the... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/downloads_spec.rb | spec/downloads_spec.rb | # frozen_string_literal: true
describe Ferrum::Downloads do
let(:filename) { "attachment.pdf" }
let(:save_path) { "/tmp/ferrum" }
def skip_browser_bug
# Also https://github.com/puppeteer/puppeteer/issues/10161
skip "https://bugs.chromium.org/p/chromium/issues/detail?id=1444729"
end
describe "#files... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/network_spec.rb | spec/network_spec.rb | # frozen_string_literal: true
describe Ferrum::Network do
describe "#traffic" do
it "keeps track of network traffic" do
page.go_to("/with_js")
urls = traffic.map { |e| e.request.url }
expect(urls.size).to eq(4)
expect(urls.grep(%r{/with_js$}).size).to eq(1)
expect(urls.grep(%r{/jqu... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/context_spec.rb | spec/context_spec.rb | # frozen_string_literal: true
describe Ferrum::Context do
describe "#windows" do
it "waits for the window to load" do
browser.go_to
browser.execute <<-JS
window.open("/slow", "popup")
JS
popup, = browser.windows(:last)
expect(popup.body).to include("slow page")
popup... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/cookies_spec.rb | spec/cookies_spec.rb | # frozen_string_literal: true
describe Ferrum::Cookies do
describe "#each" do
context "when a block is given" do
it "must yield each Cookie" do
browser.go_to("/set_cookie")
yielded_cookies = []
browser.cookies.each do |cookie| # rubocop:disable Style/MapIntoArray
yielded_... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/dialog_spec.rb | spec/dialog_spec.rb | # frozen_string_literal: true
describe Ferrum::Dialog do
describe "#accept" do
it "works with nested modals" do
browser.go_to("/with_js")
browser.on(:dialog) do |dialog, _index, _total|
if dialog.match?("Are you sure?")
dialog.accept
else
dialog.dismiss
end... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/mouse_spec.rb | spec/mouse_spec.rb | # frozen_string_literal: true
describe Ferrum::Mouse do
describe "#click" do
it "supports clicking precise coordinates" do
browser.go_to("/click_coordinates")
browser.mouse.click(x: 100, y: 150)
expect(browser.body).to include("x: 100, y: 150")
end
it "has no trouble clicking elements ... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/frame_spec.rb | spec/frame_spec.rb | # frozen_string_literal: true
describe Ferrum::Frame do
describe "#at_xpath" do
it "works correctly when JSON is overwritten" do
page.go_to("/index")
page.execute("JSON = {};")
expect { page.at_xpath("//a[text() = 'JS redirect']") }.not_to raise_error
end
end
it "supports selection by ... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/keyboard_spec.rb | spec/keyboard_spec.rb | # frozen_string_literal: true
describe Ferrum::Keyboard do
describe "#down" do
before { browser.go_to("/set") }
it "sends down events from keyboard" do
expect { browser.keyboard.down("") }.to raise_error(ArgumentError, "empty keys passed")
expect { browser.keyboard.down([]) }.to raise_error(Argu... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/headers_spec.rb | spec/headers_spec.rb | # frozen_string_literal: true
describe Ferrum::Headers do
describe "#set" do
it "allows headers to be set" do
browser.headers.set("Cookie" => "foo=bar", "YourName" => "your_value")
browser.go_to("/headers")
expect(browser.body).to include("COOKIE: foo=bar")
expect(browser.body).to include... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/browser_spec.rb | spec/browser_spec.rb | # frozen_string_literal: true
describe Ferrum::Browser do
describe "#new" do
let(:logger) { StringIO.new }
context ":browser_path argument" do
it "includes the process output in the error" do
path = "#{PROJECT_ROOT}/spec/support/broken_chrome"
expect do
Ferrum::Browser.new(b... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
require "bundler/setup"
require "rspec"
require "rspec/wait"
require "pathname"
PROJECT_ROOT = File.expand_path("..", __dir__)
%w[/lib /spec].each { |p| $LOAD_PATH.unshift(p) }
require "fileutils"
require "shellwords"
require "ferrum"
require "support/server"
require "support/global_he... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/node_spec.rb | spec/node_spec.rb | # frozen_string_literal: true
describe Ferrum::Node do
describe "#click" do
it "hovers an element before clicking it" do
browser.go_to("/with_js")
browser.at_xpath("//a[span[text() = 'Hidden link']]").click
expect(browser.current_url).to eq(base_url("/"))
end
it "fires a ping request... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/rbga_spec.rb | spec/rbga_spec.rb | # frozen_string_literal: true
describe Ferrum::RGBA do
describe "#new" do
it "raises ArgumentError for Integer value of alpha" do
expect do
Ferrum::RGBA.new(0, 0, 0, 0)
end.to raise_exception(
ArgumentError,
"Wrong alpha value 0 should be Float between 0.0 (fully transparent) ... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/support/application.rb | spec/support/application.rb | # frozen_string_literal: true
require "sinatra/base"
module Ferrum
class Application < Sinatra::Base
configure { set :protection, except: :frame_options }
FERRUM_VIEWS = "#{File.dirname(__FILE__)}/views"
FERRUM_PUBLIC = "#{File.dirname(__FILE__)}/public"
set :root, File.dirname(__FILE__)
set :... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/support/server.rb | spec/support/server.rb | # frozen_string_literal: true
require "uri"
require "net/http"
require "rack/handler/puma"
require "support/application"
module Ferrum
class Server
KILL_TIMEOUT = 60
class Middleware
class Counter
attr_reader :value
def initialize
@value = 0
@mutex = Mutex.new
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/support/global_helpers.rb | spec/support/global_helpers.rb | # frozen_string_literal: true
RSpec.shared_context "Global helpers" do
attr_reader :browser
def server
Ferrum::Server.server
end
def base_url(*args)
server.base_url(*args)
end
def page
@page ||= @browser.create_page
end
def network
page.network
end
def traffic
network.traff... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/cookies/cookie_spec.rb | spec/cookies/cookie_spec.rb | # frozen_string_literal: true
describe Ferrum::Cookies::Cookie do
let(:attributes) do
{
"name" => "OGP",
"value" => "-19027681:",
"domain" => ".google.com",
"path" => "/",
"expires" => 1_691_287_370,
"size" => 13,
"httpOnly" => false,
"secure" => false,
"sess... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/page/tracing_spec.rb | spec/page/tracing_spec.rb | # frozen_string_literal: true
describe Ferrum::Page::Tracing do
let(:file_path) { "#{PROJECT_ROOT}/spec/tmp/trace.json" }
let(:file_path2) { "#{PROJECT_ROOT}/spec/tmp/trace2.json" }
let(:file_path3) { "#{PROJECT_ROOT}/spec/tmp/trace3.json" }
let(:content) { JSON.parse(File.read(file_path)) }
let(:trace_confi... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/page/screenshot_spec.rb | spec/page/screenshot_spec.rb | # frozen_string_literal: true
require "image_size"
require "pdf/reader"
require "chunky_png"
require "ferrum/rgba"
describe Ferrum::Page::Screenshot do
shared_examples "screenshot screen" do
it "supports screenshotting the whole of a page that goes outside the viewport" do
browser.go_to("/long_page")
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/page/animation_spec.rb | spec/page/animation_spec.rb | # frozen_string_literal: true
describe Ferrum::Page::Animation do
describe "#playback_rate" do
it "gets default playback rate" do
browser.go_to("/animation")
expect(browser.playback_rate).to eq(1)
end
end
describe "#playback_rate=" do
it "sets playback rate" do
browser.playback_ra... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/page/screencast_spec.rb | spec/page/screencast_spec.rb | # frozen_string_literal: true
require "base64"
require "image_size"
require "pdf/reader"
require "chunky_png"
require "ferrum/rgba"
describe Ferrum::Page::Screencast do
let(:format) { :jpeg }
after(:example) { browser.stop_screencast }
describe "#start_screencast" do
context "when the page has no changing... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/unit/browser_spec.rb | spec/unit/browser_spec.rb | # frozen_string_literal: true
require "stringio"
require "logger"
describe Ferrum::Browser do
it "logs requests and responses with native Logger" do
custom_logger = Class.new do
def initialize(logger)
@logger = logger
end
def puts(*args)
@logger << args
end
end
f... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/unit/process_spec.rb | spec/unit/process_spec.rb | # frozen_string_literal: true
describe Ferrum::Browser::Process do
subject { Ferrum::Browser.new(port: 6000, host: "127.0.0.1") }
unless Ferrum::Utils::Platform.windows?
it "forcibly kills the child if it does not respond to SIGTERM" do
allow(Process).to receive(:spawn).and_return(5678)
allow(Proc... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/frame/runtime_spec.rb | spec/frame/runtime_spec.rb | # frozen_string_literal: true
describe Ferrum::Frame::Runtime do
describe "#execute" do
it "executes multiple lines of javascript" do
browser.execute <<-JS
var a = 1
var b = 2
window.result = a + b
JS
expect(browser.evaluate("window.result")).to eq(3)
end
contex... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/network/exchange_spec.rb | spec/network/exchange_spec.rb | # frozen_string_literal: true
describe Ferrum::Network::Exchange do
describe "#url" do
it "returns url of the request" do
page.go_to
expect(last_exchange.url).to eq("http://127.0.0.1:#{server.port}/")
end
it "returns nil when request is blank" do
page.go_to
allow(last_exchange)... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/network/response_spec.rb | spec/network/response_spec.rb | # frozen_string_literal: true
describe Ferrum::Network::Response do
describe "#status" do
it "captures responses" do
page.go_to("/with_js")
expect(last_exchange.response.status).to eq(200)
end
it "determines status from the simple response" do
browser.go_to("/status/500")
expect... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/network/auth_request_spec.rb | spec/network/auth_request_spec.rb | # frozen_string_literal: true
describe Ferrum::Network::AuthRequest do
skip
end
| ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/network/request_spec.rb | spec/network/request_spec.rb | # frozen_string_literal: true
describe Ferrum::Network::Request do
describe "#ping?" do
it "returns false for document requests" do
request = Ferrum::Network::Request.new({ "type" => "Document" })
expect(request.ping?).to be(false)
end
it "returns true for ping requests" do
request = ... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/network/intercepted_request_spec.rb | spec/network/intercepted_request_spec.rb | # frozen_string_literal: true
describe Ferrum::Network::InterceptedRequest do
skip
end
| ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/network/error_spec.rb | spec/network/error_spec.rb | # frozen_string_literal: true
describe Ferrum::Network::Error do
it "#canceled?" do
page.go_to("/with_ajax_connection_canceled")
expect(network.idle?).to be_falsey
# FIXME: Hack to wait for content in the browser
Ferrum::Utils::Attempt.with_retry(errors: RuntimeError, max: 10, wait: 0.1) do
p... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/browser/version_info_spec.rb | spec/browser/version_info_spec.rb | # frozen_string_literal: true
describe Ferrum::Browser::VersionInfo do
let(:protocol_version) { "1.3" }
let(:product) { "HeadlessChrome/106.0.5249.91" }
let(:revision) { "@fa96d5f07b1177d1bf5009f647a5b8c629762157" }
let(:user_agent) do
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/browser/xvfb_spec.rb | spec/browser/xvfb_spec.rb | # frozen_string_literal: true
describe Ferrum::Browser::Xvfb, skip: !Ferrum::Browser::Binary.find("Xvfb") do
let(:process) { xvfb_browser.process }
let(:xvfb_browser) { Ferrum::Browser.new(default_options.merge(options)) }
let(:default_options) { Hash(headless: true, xvfb: true) }
context "headless" do
co... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/browser/binary_spec.rb | spec/browser/binary_spec.rb | # frozen_string_literal: true
describe Ferrum::Browser::Binary do
let(:tmp_bin) { "#{PROJECT_ROOT}/spec/tmp/bin" }
let(:bin1) { File.join(tmp_bin, "bin1") }
let(:bin1_exe) { File.join(tmp_bin, "bin1.exe") }
let(:bin2_no_x) { File.join(tmp_bin, "/bin2") }
let(:bin3) { File.join(tmp_bin, "/bin3") }
let(:bin4... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/spec/browser/options/chrome_spec.rb | spec/browser/options/chrome_spec.rb | # frozen_string_literal: true
describe Ferrum::Browser::Options::Chrome do
let(:defaults) { described_class.options }
let(:options) { Ferrum::Browser::Options.new }
describe "#merge_default" do
it "includes --disable-gpu flag on windows" do
allow(Ferrum::Utils::Platform).to receive(:windows?).and_retu... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum.rb | lib/ferrum.rb | # frozen_string_literal: true
require "concurrent-ruby"
require "ferrum/utils/event"
require "ferrum/utils/thread"
require "ferrum/utils/platform"
require "ferrum/utils/elapsed_time"
require "ferrum/utils/attempt"
require "ferrum/errors"
require "ferrum/browser"
require "ferrum/node"
module Ferrum
end
| ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/target.rb | lib/ferrum/target.rb | # frozen_string_literal: true
module Ferrum
class Target
NEW_WINDOW_WAIT = ENV.fetch("FERRUM_NEW_WINDOW_WAIT", 0.3).to_f
# You can create page yourself and assign it to target, used in cuprite
# where we enhance page class and build page ourselves.
attr_writer :page
attr_reader :options
att... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/cookies.rb | lib/ferrum/cookies.rb | # frozen_string_literal: true
require "yaml"
require "ferrum/cookies/cookie"
module Ferrum
class Cookies
include Enumerable
def initialize(page)
@page = page
end
#
# Enumerates over all cookies.
#
# @yield [cookie]
# The given block will be passed each cookie.
#
# @... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/version.rb | lib/ferrum/version.rb | # frozen_string_literal: true
module Ferrum
VERSION = "0.17.1"
end
| ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/mouse.rb | lib/ferrum/mouse.rb | # frozen_string_literal: true
module Ferrum
class Mouse
CLICK_WAIT = ENV.fetch("FERRUM_CLICK_WAIT", 0.1).to_f
BUTTON_MASKS = {
"none" => 0,
"left" => 1,
"right" => 2,
"middle" => 4,
"back" => 8,
"forward" => 16
}.freeze
def initialize(page)
@page = page
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/errors.rb | lib/ferrum/errors.rb | # frozen_string_literal: true
module Ferrum
class Error < StandardError; end
class NoSuchPageError < Error; end
class NoSuchTargetError < Error; end
class NotImplementedError < Error; end
class BinaryNotFoundError < Error; end
class EmptyPathError < Error; end
class ServerError ... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/network.rb | lib/ferrum/network.rb | # frozen_string_literal: true
require "ferrum/network/exchange"
require "ferrum/network/intercepted_request"
require "ferrum/network/auth_request"
require "ferrum/network/error"
require "ferrum/network/request"
require "ferrum/network/response"
module Ferrum
class Network
CLEAR_TYPE = %i[traffic cache].freeze
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/frame.rb | lib/ferrum/frame.rb | # frozen_string_literal: true
require "ferrum/frame/dom"
require "ferrum/frame/runtime"
module Ferrum
class Frame
include DOM
include Runtime
STATE_VALUES = %i[
started_loading
navigated
stopped_loading
].freeze
# The Frame's unique id.
#
# @return [String]
attr_a... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/page.rb | lib/ferrum/page.rb | # frozen_string_literal: true
require "forwardable"
require "pathname"
require "ferrum/mouse"
require "ferrum/keyboard"
require "ferrum/headers"
require "ferrum/cookies"
require "ferrum/dialog"
require "ferrum/network"
require "ferrum/downloads"
require "ferrum/page/frames"
require "ferrum/page/screencast"
require "fe... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/browser.rb | lib/ferrum/browser.rb | # frozen_string_literal: true
require "base64"
require "forwardable"
require "ferrum/page"
require "ferrum/proxy"
require "ferrum/client"
require "ferrum/contexts"
require "ferrum/browser/xvfb"
require "ferrum/browser/options"
require "ferrum/browser/process"
require "ferrum/browser/binary"
require "ferrum/browser/ver... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/proxy.rb | lib/ferrum/proxy.rb | # frozen_string_literal: true
require "tempfile"
require "webrick"
require "webrick/httpproxy"
module Ferrum
class Proxy
def self.start(**args)
new(**args).tap(&:start)
end
attr_reader :host, :port, :user, :password
def initialize(host: "127.0.0.1", port: 0, user: nil, password: nil)
@... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/node.rb | lib/ferrum/node.rb | # frozen_string_literal: true
module Ferrum
class Node
MOVING_WAIT_DELAY = ENV.fetch("FERRUM_NODE_MOVING_WAIT", 0.01).to_f
MOVING_WAIT_ATTEMPTS = ENV.fetch("FERRUM_NODE_MOVING_ATTEMPTS", 50).to_i
attr_reader :page, :target_id, :node_id, :description, :tag_name
def initialize(frame, target_id, node_... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/downloads.rb | lib/ferrum/downloads.rb | # frozen_string_literal: true
module Ferrum
class Downloads
VALID_BEHAVIOR = %i[deny allow allowAndName default].freeze
def initialize(page)
@page = page
@event = Utils::Event.new.tap(&:set)
@files = {}
end
def files
@files.values
end
def wait(timeout = 5)
@ev... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/client.rb | lib/ferrum/client.rb | # frozen_string_literal: true
require "concurrent-ruby"
require "forwardable"
require "ferrum/client/subscriber"
require "ferrum/client/web_socket"
require "ferrum/utils/thread"
module Ferrum
class SessionClient
attr_reader :client, :session_id
def self.event_name(event, session_id)
[event, session_i... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/context.rb | lib/ferrum/context.rb | # frozen_string_literal: true
require "ferrum/target"
module Ferrum
class Context
POSITION = %i[first last].freeze
attr_reader :id, :targets
def initialize(client, contexts, id)
@id = id
@client = client
@contexts = contexts
@targets = Concurrent::Map.new
@pendings = Conc... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/headers.rb | lib/ferrum/headers.rb | # frozen_string_literal: true
module Ferrum
class Headers
def initialize(page)
@page = page
@headers = {}
end
#
# Get all headers.
#
# @return [Hash{String => String}]
#
def get
@headers
end
#
# Set given headers. Eventually clear all headers and set gi... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/keyboard.rb | lib/ferrum/keyboard.rb | # frozen_string_literal: true
require "json"
module Ferrum
class Keyboard
KEYS = JSON.parse(File.read(File.expand_path("keyboard.json", __dir__)))
MODIFIERS = { "alt" => 1, "ctrl" => 2, "control" => 2,
"meta" => 4, "command" => 4, "shift" => 8 }.freeze
KEYS_MAPPING = {
cancel: "C... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/contexts.rb | lib/ferrum/contexts.rb | # frozen_string_literal: true
require "ferrum/context"
module Ferrum
class Contexts
ALLOWED_TARGET_TYPES = %w[page iframe].freeze
include Enumerable
attr_reader :contexts
def initialize(client)
@contexts = Concurrent::Map.new
@client = client
subscribe
auto_attach
di... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/dialog.rb | lib/ferrum/dialog.rb | # frozen_string_literal: true
module Ferrum
class Dialog
attr_reader :message, :default_prompt
def initialize(page, params)
@page = page
@message = params["message"]
@default_prompt = params["defaultPrompt"]
end
#
# Accept dialog with given text or default prompt if applicable... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/rgba.rb | lib/ferrum/rgba.rb | # frozen_string_literal: true
module Ferrum
class RGBA
def initialize(red, green, blue, alpha)
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
validate
end
def to_h
{ r: red, g: green, b: blue, a: alpha }
end
private
attr_accessor ... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/cookies/cookie.rb | lib/ferrum/cookies/cookie.rb | # frozen_string_literal: true
module Ferrum
class Cookies
#
# Represents a [cookie value](https://chromedevtools.github.io/devtools-protocol/1-3/Network/#type-Cookie).
#
class Cookie
# The parsed JSON attributes.
#
# @return [Hash{String => [String, Boolean, nil]}]
attr_reader... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/utils/platform.rb | lib/ferrum/utils/platform.rb | # frozen_string_literal: true
module Ferrum
module Utils
module Platform
module_function
def name
return :mac if mac?
return :windows if windows?
:linux
end
def windows?
RbConfig::CONFIG["host_os"] =~ /mingw|mswin|cygwin/
end
def mac?
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/utils/event.rb | lib/ferrum/utils/event.rb | # frozen_string_literal: true
module Ferrum
module Utils
class Event < Concurrent::Event
def iteration
synchronize { @iteration }
end
def reset
synchronize do
@iteration += 1
@set = false if @set
@iteration
end
end
end
end
end
| ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/utils/thread.rb | lib/ferrum/utils/thread.rb | # frozen_string_literal: true
module Ferrum
module Utils
module Thread
module_function
def spawn(abort_on_exception: true)
::Thread.new(abort_on_exception) do |whether_abort_on_exception|
::Thread.current.abort_on_exception = whether_abort_on_exception
::Thread.current.re... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/utils/attempt.rb | lib/ferrum/utils/attempt.rb | # frozen_string_literal: true
module Ferrum
module Utils
module Attempt
module_function
def with_retry(errors:, max:, wait:)
attempts ||= 1
yield
rescue *Array(errors)
raise if attempts >= max
attempts += 1
sleep(wait)
retry
end
end
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/utils/elapsed_time.rb | lib/ferrum/utils/elapsed_time.rb | # frozen_string_literal: true
module Ferrum
module Utils
module ElapsedTime
module_function
def start
@start ||= monotonic_time
end
def reset
@start = monotonic_time
end
def elapsed_time(start = nil)
monotonic_time - (start || @start)
end
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/page/stream.rb | lib/ferrum/page/stream.rb | # frozen_string_literal: true
module Ferrum
class Page
module Stream
STREAM_CHUNK = 128 * 1024
def stream_to(path:, encoding:, handle:)
if path.nil?
stream_to_memory(encoding: encoding, handle: handle)
else
stream_to_file(path: path, handle: handle)
end
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/page/screencast.rb | lib/ferrum/page/screencast.rb | # frozen_string_literal: true
module Ferrum
class Page
module Screencast
# Starts sending frames to record screencast to the given block.
#
# @param [Hash{Symbol => Object}] opts
#
# @option opts [:jpeg, :png] :format
# The format the image should be returned in.
#
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/page/frames.rb | lib/ferrum/page/frames.rb | # frozen_string_literal: true
require "ferrum/frame"
module Ferrum
class Page
module Frames
# The page's main frame, the top of the tree and the parent of all frames.
#
# @return [Frame]
attr_reader :main_frame
#
# Returns all the frames current page have.
#
# @r... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/page/screenshot.rb | lib/ferrum/page/screenshot.rb | # frozen_string_literal: true
require "ferrum/rgba"
module Ferrum
class Page
module Screenshot
FULL_WARNING = "Ignoring :selector or :area in #screenshot since full: true was given at %s"
AREA_WARNING = "Ignoring :area in #screenshot since selector: was given at %s"
DEFAULT_SCREENSHOT_FORMAT ... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/page/animation.rb | lib/ferrum/page/animation.rb | # frozen_string_literal: true
module Ferrum
class Page
module Animation
#
# Returns playback rate for CSS animations, defaults to `1`.
#
# @return [Integer]
#
def playback_rate
command("Animation.getPlaybackRate")["playbackRate"]
end
#
# Sets playbac... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/page/tracing.rb | lib/ferrum/page/tracing.rb | # frozen_string_literal: true
module Ferrum
class Page
class Tracing
EXCLUDED_CATEGORIES = %w[*].freeze
SCREENSHOT_CATEGORIES = %w[disabled-by-default-devtools.screenshot].freeze
INCLUDED_CATEGORIES = %w[devtools.timeline v8.execute disabled-by-default-devtools.timeline
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/frame/runtime.rb | lib/ferrum/frame/runtime.rb | # frozen_string_literal: true
require "singleton"
module Ferrum
class CyclicObject
include Singleton
def inspect
%(#<#{self.class} JavaScript object that cannot be represented in Ruby>)
end
end
class Frame
module Runtime
INTERMITTENT_ATTEMPTS = ENV.fetch("FERRUM_INTERMITTENT_ATTEMP... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/frame/dom.rb | lib/ferrum/frame/dom.rb | # frozen_string_literal: true
# RemoteObjectId is from a JavaScript world, and corresponds to any JavaScript
# object, including JS wrappers for DOM nodes. There is a way to convert between
# node ids and remote object ids (DOM.requestNode and DOM.resolveNode).
#
# NodeId is used for inspection, when backend tracks th... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/network/request_params.rb | lib/ferrum/network/request_params.rb | # frozen_string_literal: true
module Ferrum
class Network
#
# Common methods used by both {Request} and {InterceptedRequest}.
#
module RequestParams
#
# The URL for the request.
#
# @return [String]
#
def url
@request["url"]
end
#
# The U... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/network/intercepted_request.rb | lib/ferrum/network/intercepted_request.rb | # frozen_string_literal: true
require "ferrum/network/request_params"
require "base64"
module Ferrum
class Network
class InterceptedRequest
include RequestParams
attr_accessor :request_id, :frame_id, :resource_type, :network_id, :status
def initialize(client, params)
@status = nil
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/network/auth_request.rb | lib/ferrum/network/auth_request.rb | # frozen_string_literal: true
module Ferrum
class Network
class AuthRequest
attr_accessor :request_id, :frame_id, :resource_type
def initialize(page, params)
@page = page
@params = params
@request_id = params["requestId"]
@frame_id = params["frameId"]
@resourc... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/network/exchange.rb | lib/ferrum/network/exchange.rb | # frozen_string_literal: true
module Ferrum
class Network
class Exchange
# ID of the request.
#
# @return String
attr_reader :id
# The intercepted request.
#
# @return [InterceptedRequest, nil]
attr_accessor :intercepted_request
# The request object.
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/network/response.rb | lib/ferrum/network/response.rb | # frozen_string_literal: true
module Ferrum
class Network
#
# Represents a [Network.Response](https://chromedevtools.github.io/devtools-protocol/1-3/Network/#type-Response)
# object.
#
class Response
# The response body size.
#
# @return [Integer, nil]
attr_reader :body_si... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/network/request.rb | lib/ferrum/network/request.rb | # frozen_string_literal: true
require "ferrum/network/request_params"
require "time"
module Ferrum
class Network
#
# Represents a [Network.Request](https://chromedevtools.github.io/devtools-protocol/1-3/Network/#type-Request)
# object.
#
class Request
include RequestParams
#
#... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/network/error.rb | lib/ferrum/network/error.rb | # frozen_string_literal: true
module Ferrum
class Network
class Error
attr_writer :canceled
attr_reader :time, :timestamp
attr_accessor :id, :url, :type, :error_text, :monotonic_time, :description
def canceled?
@canceled
end
def timestamp=(value)
@timestamp =... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/client/subscriber.rb | lib/ferrum/client/subscriber.rb | # frozen_string_literal: true
module Ferrum
class Client
class Subscriber
INTERRUPTIONS = %w[Fetch.requestPaused Fetch.authRequired].freeze
def initialize
@regular = Queue.new
@priority = Queue.new
@on = Concurrent::Hash.new
start
end
def <<(message)
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/client/web_socket.rb | lib/ferrum/client/web_socket.rb | # frozen_string_literal: true
require "json"
require "socket"
require "websocket/driver"
module Ferrum
class Client
class WebSocket
WEBSOCKET_BUG_SLEEP = 0.05
DEFAULT_PORTS = { "ws" => 80, "wss" => 443 }.freeze
SKIP_LOGGING_SCREENSHOTS = !ENV["FERRUM_LOGGING_SCREENSHOTS"]
attr_reader :u... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/browser/xvfb.rb | lib/ferrum/browser/xvfb.rb | # frozen_string_literal: true
module Ferrum
class Browser
class Xvfb
NOT_FOUND = "Could not find an executable for the Xvfb. Try to install " \
"it with your package manager"
def self.start(*args)
new(*args).tap(&:start)
end
attr_reader :screen_size, :display_i... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/browser/command.rb | lib/ferrum/browser/command.rb | # frozen_string_literal: true
module Ferrum
class Browser
class Command
NOT_FOUND = "Could not find an executable for the browser. Try to make " \
"it available on the PATH or set environment variable for " \
"example BROWSER_PATH=\"/usr/bin/chrome\""
# Currently ... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/browser/version_info.rb | lib/ferrum/browser/version_info.rb | # frozen_string_literal: true
module Ferrum
class Browser
#
# The browser's version information returned by [Browser.getVersion].
#
# [Browser.getVersion]: https://chromedevtools.github.io/devtools-protocol/1-3/Browser/#method-getVersion
#
# @since 0.13
#
class VersionInfo
#
... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/browser/binary.rb | lib/ferrum/browser/binary.rb | # frozen_string_literal: true
module Ferrum
class Browser
module Binary
module_function
def find(commands)
enum(commands).first
end
def all(commands)
enum(commands).force
end
def enum(commands)
paths, exts = prepare_paths
cmds = Array(command... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/browser/options.rb | lib/ferrum/browser/options.rb | # frozen_string_literal: true
module Ferrum
class Browser
class Options
BROWSER_PORT = "0"
BROWSER_HOST = "127.0.0.1"
WINDOW_SIZE = [1024, 768].freeze
BASE_URL_SCHEMA = %w[http https].freeze
DEFAULT_TIMEOUT = ENV.fetch("FERRUM_DEFAULT_TIMEOUT", 5).to_i
PROCESS_TIMEOUT = ENV.fe... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/browser/process.rb | lib/ferrum/browser/process.rb | # frozen_string_literal: true
require "net/http"
require "json"
require "addressable"
require "tmpdir"
require "forwardable"
require "ferrum/browser/options/base"
require "ferrum/browser/options/chrome"
require "ferrum/browser/options/firefox"
require "ferrum/browser/command"
require "ferrum/utils/elapsed_time"
requir... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
rubycdp/ferrum | https://github.com/rubycdp/ferrum/blob/bd9b9019ad12475126b7562179b3c11270b5e9bd/lib/ferrum/browser/options/chrome.rb | lib/ferrum/browser/options/chrome.rb | # frozen_string_literal: true
module Ferrum
class Browser
class Options
class Chrome < Base
DEFAULT_OPTIONS = {
"headless" => nil,
"hide-scrollbars" => nil,
"mute-audio" => nil,
"enable-automation" => nil,
"disable-web-security" => nil,
"d... | ruby | MIT | bd9b9019ad12475126b7562179b3c11270b5e9bd | 2026-01-04T15:59:29.143722Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.