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 |
|---|---|---|---|---|---|---|---|---|
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/spec/rspec/features_spec.rb | spec/rspec/features_spec.rb | # frozen_string_literal: true
# rubocop:disable RSpec/MultipleDescribes
require 'spec_helper'
require 'capybara/rspec'
# rubocop:disable RSpec/InstanceVariable
RSpec.configuration.before(:each, file_path: './spec/rspec/features_spec.rb') do
@in_filtered_hook = true
end
feature "Capybara's feature DSL" do
backgr... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/spec/rspec/views_spec.rb | spec/rspec/views_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'capybara/rspec', type: :view do
it 'allows matchers to be used on strings' do
html = %(<h1>Test header</h1>)
expect(html).to have_css('h1', text: 'Test header')
end
it "doesn't include RSpecMatcherProxies" do
expect(self.class.ance... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/spec/rspec/scenarios_spec.rb | spec/rspec/scenarios_spec.rb | # frozen_string_literal: true
# rubocop:disable RSpec/MultipleDescribes
require 'spec_helper'
require 'capybara/rspec'
RSpec.configuration.before(:each, file_path: './spec/rspec/scenarios_spec.rb') do
@in_filtered_hook = true
end
feature 'if fscenario aliases focused tag then' do
fscenario 'scenario should have... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/spec/fixtures/selenium_driver_rspec_failure.rb | spec/fixtures/selenium_driver_rspec_failure.rb | # frozen_string_literal: true
require 'spec_helper'
require 'selenium-webdriver'
RSpec.describe Capybara::Selenium::Driver do
it 'should exit with a non-zero exit status' do
options = { browser: ENV.fetch('SELENIUM_BROWSER', :firefox).to_sym }
browser = described_class.new(TestApp, options).browser
expe... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/spec/fixtures/selenium_driver_rspec_success.rb | spec/fixtures/selenium_driver_rspec_success.rb | # frozen_string_literal: true
require 'spec_helper'
require 'selenium-webdriver'
RSpec.describe Capybara::Selenium::Driver do
it 'should exit with a zero exit status' do
options = { browser: ENV.fetch('SELENIUM_BROWSER', :firefox).to_sym }
browser = described_class.new(TestApp, **options).browser
expect... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara.rb | lib/capybara.rb | # frozen_string_literal: true
require 'timeout'
require 'nokogiri'
require 'xpath'
require 'forwardable'
require 'capybara/config'
require 'capybara/registration_container'
module Capybara
class CapybaraError < StandardError; end
class DriverNotFoundError < CapybaraError; end
class FrozenInTime < CapybaraError;... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector.rb | lib/capybara/selector.rb | # frozen_string_literal: true
require 'capybara/selector/xpath_extensions'
require 'capybara/selector/selector'
require 'capybara/selector/definition'
#
# All Selectors below support the listed selector specific filters in addition to the following system-wide filters
# * :id (String, Regexp, XPath::Expression) - M... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/cucumber.rb | lib/capybara/cucumber.rb | # frozen_string_literal: true
require 'capybara/dsl'
require 'capybara/rspec/matchers'
require 'capybara/rspec/matcher_proxies'
World(Capybara::DSL)
World(Capybara::RSpecMatchers)
After do
Capybara.reset_sessions!
end
Before do
Capybara.use_default_driver
end
Before '@javascript' do
Capybara.current_driver =... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/session.rb | lib/capybara/session.rb | # frozen_string_literal: true
require 'capybara/session/matchers'
require 'addressable/uri'
module Capybara
##
#
# The {Session} class represents a single user's interaction with the system. The {Session} can use
# any of the underlying drivers. A session can be initialized manually like this:
#
# ses... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | true |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/version.rb | lib/capybara/version.rb | # frozen_string_literal: true
module Capybara
VERSION = '3.40.0'
end
| ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rails.rb | lib/capybara/rails.rb | # frozen_string_literal: true
require 'capybara/dsl'
Capybara.app = Rack::Builder.new do
map '/' do
run Rails.application
end
end.to_app
Capybara.save_path = Rails.root.join('tmp/capybara')
# Override default rack_test driver to respect data-method attributes.
Capybara.register_driver :rack_test do |app|
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/window.rb | lib/capybara/window.rb | # frozen_string_literal: true
module Capybara
##
# The {Window} class represents a browser window.
#
# You can get an instance of the class by calling any of:
#
# * {Capybara::Session#windows}
# * {Capybara::Session#current_window}
# * {Capybara::Session#window_opened_by}
# * {Capybara::Session#switc... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/result.rb | lib/capybara/result.rb | # frozen_string_literal: true
require 'forwardable'
module Capybara
##
# A {Capybara::Result} represents a collection of {Capybara::Node::Element} on the page. It is possible to interact with this
# collection similar to an Array because it implements Enumerable and offers the following Array methods through de... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/helpers.rb | lib/capybara/helpers.rb | # frozen_string_literal: true
module Capybara
# @api private
module Helpers
module_function
##
# @deprecated
# Normalizes whitespace space by stripping leading and trailing
# whitespace and replacing sequences of whitespace characters
# with a single space.
#
# @param [String] text ... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/dsl.rb | lib/capybara/dsl.rb | # frozen_string_literal: true
require 'capybara'
module Capybara
module DSL
def self.included(base)
warn 'including Capybara::DSL in the global scope is not recommended!' if base == Object
super
end
def self.extended(base)
warn 'extending the main object with Capybara::DSL is not reco... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/minitest.rb | lib/capybara/minitest.rb | # frozen_string_literal: true
require 'minitest'
require 'capybara/dsl'
module Capybara
module Minitest
module Assertions
##
# Assert text exists
#
# @!method assert_content
# @!method assert_text
# See {Capybara::Node::Matchers#assert_text}
##
# Assert text do... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/registration_container.rb | lib/capybara/registration_container.rb | # frozen_string_literal: true
module Capybara
# @api private
class RegistrationContainer
def names
@registered.keys
end
def [](name)
@registered[name]
end
def []=(name, value)
Capybara::Helpers.warn 'DEPRECATED: Directly setting drivers/servers is deprecated, please use Capy... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/config.rb | lib/capybara/config.rb | # frozen_string_literal: true
require 'forwardable'
require 'capybara/session/config'
module Capybara
class Config
extend Forwardable
OPTIONS = %i[
app reuse_server threadsafe server default_driver javascript_driver use_html5_parsing allow_gumbo
].freeze
attr_accessor :app, :use_html5_parsin... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/server.rb | lib/capybara/server.rb | # frozen_string_literal: true
require 'uri'
require 'net/http'
require 'rack'
require 'capybara/server/middleware'
require 'capybara/server/animation_disabler'
require 'capybara/server/checker'
module Capybara
# @api private
class Server
class << self
def ports
@ports ||= {}
end
end
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec.rb | lib/capybara/rspec.rb | # frozen_string_literal: true
require 'rspec/core'
require 'capybara/dsl'
require 'capybara/rspec/matchers'
require 'capybara/rspec/features'
require 'capybara/rspec/matcher_proxies'
RSpec.configure do |config|
config.include Capybara::DSL, type: :feature
config.include Capybara::RSpecMatchers, type: :feature
c... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/minitest/spec.rb | lib/capybara/minitest/spec.rb | # frozen_string_literal: true
require 'minitest/spec'
module Capybara
module Minitest
module Expectations
##
# Expectation that there is an ancestor
#
# @!method must_have_ancestor
# See {Capybara::Node::Matchers#has_ancestor?}
##
# Expectation that there is button
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers.rb | lib/capybara/rspec/matchers.rb | # frozen_string_literal: true
require 'capybara/rspec/matchers/have_selector'
require 'capybara/rspec/matchers/have_ancestor'
require 'capybara/rspec/matchers/have_sibling'
require 'capybara/rspec/matchers/match_selector'
require 'capybara/rspec/matchers/have_current_path'
require 'capybara/rspec/matchers/match_style'... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matcher_proxies.rb | lib/capybara/rspec/matcher_proxies.rb | # frozen_string_literal: true
module Capybara
module RSpecMatcherProxies
def all(*args, **kwargs, &block)
if defined?(::RSpec::Matchers::BuiltIn::All) && args.first.respond_to?(:matches?)
::RSpec::Matchers::BuiltIn::All.new(*args)
else
find_all(*args, **kwargs, &block)
end
e... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/features.rb | lib/capybara/rspec/features.rb | # frozen_string_literal: true
RSpec.shared_context 'Capybara Features', capybara_feature: true do
instance_eval do
alias background before
alias given let
alias given! let!
end
end
# ensure shared_context is included if default shared_context_metadata_behavior is changed
RSpec.configure do |config|
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/count_sugar.rb | lib/capybara/rspec/matchers/count_sugar.rb | # frozen_string_literal: true
module Capybara
module RSpecMatchers
module CountSugar
def once; exactly(1); end
def twice; exactly(2); end
def thrice; exactly(3); end
def exactly(number)
options[:count] = number
self
end
def at_most(number)
options[:ma... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/have_text.rb | lib/capybara/rspec/matchers/have_text.rb | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveText < CountableWrappedElementMatcher
def element_matches?(el)
el.assert_text(*@args, **@kw_args)
end
def element_does_not_match?(el)
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/have_ancestor.rb | lib/capybara/rspec/matchers/have_ancestor.rb | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveAncestor < CountableWrappedElementMatcher
def element_matches?(el)
el.assert_ancestor(*@args, **session_query_options, &@filter_block)
end
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/have_sibling.rb | lib/capybara/rspec/matchers/have_sibling.rb | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveSibling < CountableWrappedElementMatcher
def element_matches?(el)
el.assert_sibling(*@args, **session_query_options, &@filter_block)
end
de... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/have_selector.rb | lib/capybara/rspec/matchers/have_selector.rb | # frozen_string_literal: true
# rubocop:disable Naming/PredicatePrefix
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveSelector < CountableWrappedElementMatcher
def initialize(*args, **kw_args, &filter_block)
super
return u... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/match_selector.rb | lib/capybara/rspec/matchers/match_selector.rb | # frozen_string_literal: true
require 'capybara/rspec/matchers/have_selector'
module Capybara
module RSpecMatchers
module Matchers
class MatchSelector < HaveSelector
def element_matches?(el)
el.assert_matches_selector(*@args, **session_query_options, &@filter_block)
end
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/have_title.rb | lib/capybara/rspec/matchers/have_title.rb | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveTitle < WrappedElementMatcher
def element_matches?(el)
el.assert_title(*@args, **@kw_args)
end
def element_does_not_match?(el)
el... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/have_current_path.rb | lib/capybara/rspec/matchers/have_current_path.rb | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveCurrentPath < WrappedElementMatcher
def element_matches?(el)
el.assert_current_path(current_path, **@kw_args, &@filter_block)
end
def eleme... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/base.rb | lib/capybara/rspec/matchers/base.rb | # frozen_string_literal: true
require 'capybara/rspec/matchers/compound'
require 'capybara/rspec/matchers/count_sugar'
require 'capybara/rspec/matchers/spatial_sugar'
module Capybara
module RSpecMatchers
module Matchers
class Base
include ::Capybara::RSpecMatchers::Matchers::Compound if defined?(:... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/compound.rb | lib/capybara/rspec/matchers/compound.rb | # frozen_string_literal: true
if defined?(RSpec::Expectations::Version)
module Capybara
module RSpecMatchers
module Matchers
module Compound
include ::RSpec::Matchers::Composable
def and(matcher)
And.new(self, matcher)
end
def and_then(matcher)
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/match_style.rb | lib/capybara/rspec/matchers/match_style.rb | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class MatchStyle < WrappedElementMatcher
def initialize(styles = nil, **kw_args, &filter_block)
styles, kw_args = kw_args, {} if styles.nil?
super(styles, *... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/spatial_sugar.rb | lib/capybara/rspec/matchers/spatial_sugar.rb | # frozen_string_literal: true
module Capybara
module RSpecMatchers
module SpatialSugar
def above(el)
options[:above] = el
self
end
def below(el)
options[:below] = el
self
end
def left_of(el)
options[:left_of] = el
self
end
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/rspec/matchers/become_closed.rb | lib/capybara/rspec/matchers/become_closed.rb | # frozen_string_literal: true
module Capybara
module RSpecMatchers
module Matchers
class BecomeClosed
def initialize(options)
@options = options
end
def matches?(window)
@window = window
@wait_time = Capybara::Queries::BaseQuery.wait(@options, window.s... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/driver.rb | lib/capybara/selenium/driver.rb | # frozen_string_literal: true
require 'uri'
require 'English'
class Capybara::Selenium::Driver < Capybara::Driver::Base
include Capybara::Selenium::Find
DEFAULT_OPTIONS = {
browser: :firefox,
clear_local_storage: nil,
clear_session_storage: nil
}.freeze
SPECIAL_OPTIONS = %i[browser clear_local_st... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/node.rb | lib/capybara/selenium/node.rb | # frozen_string_literal: true
# Selenium specific implementation of the Capybara::Driver::Node API
require 'capybara/selenium/extensions/find'
require 'capybara/selenium/extensions/scroll'
require 'capybara/node/whitespace_normalizer'
class Capybara::Selenium::Node < Capybara::Driver::Node
include Capybara::Node::... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/nodes/edge_node.rb | lib/capybara/selenium/nodes/edge_node.rb | # frozen_string_literal: true
require 'capybara/selenium/extensions/html5_drag'
class Capybara::Selenium::EdgeNode < Capybara::Selenium::Node
include Html5Drag
def set_text(value, clear: nil, **_unused)
return super unless chrome_edge?
super.tap do
# React doesn't see the chromedriver element clea... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/nodes/firefox_node.rb | lib/capybara/selenium/nodes/firefox_node.rb | # frozen_string_literal: true
require 'capybara/selenium/extensions/html5_drag'
require 'capybara/selenium/extensions/file_input_click_emulation'
class Capybara::Selenium::FirefoxNode < Capybara::Selenium::Node
include Html5Drag
include FileInputClickEmulation
def click(keys = [], **options)
super
rescue... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/nodes/safari_node.rb | lib/capybara/selenium/nodes/safari_node.rb | # frozen_string_literal: true
# require 'capybara/selenium/extensions/html5_drag'
require 'capybara/selenium/extensions/modifier_keys_stack'
class Capybara::Selenium::SafariNode < Capybara::Selenium::Node
# include Html5Drag
def click(keys = [], **options)
# driver.execute_script('arguments[0].scrollIntoView... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/nodes/ie_node.rb | lib/capybara/selenium/nodes/ie_node.rb | # frozen_string_literal: true
require 'capybara/selenium/extensions/html5_drag'
class Capybara::Selenium::IENode < Capybara::Selenium::Node
def disabled?
# super
# optimize to one script call
driver.evaluate_script <<~JS.delete("\n"), self
arguments[0].msMatchesSelector('
:disabled,
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/nodes/chrome_node.rb | lib/capybara/selenium/nodes/chrome_node.rb | # frozen_string_literal: true
require 'capybara/selenium/extensions/html5_drag'
require 'capybara/selenium/extensions/file_input_click_emulation'
class Capybara::Selenium::ChromeNode < Capybara::Selenium::Node
include Html5Drag
include FileInputClickEmulation
def set_text(value, clear: nil, **_unused)
supe... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/extensions/file_input_click_emulation.rb | lib/capybara/selenium/extensions/file_input_click_emulation.rb | # frozen_string_literal: true
class Capybara::Selenium::Node
module FileInputClickEmulation
def click(keys = [], **options)
super
rescue Selenium::WebDriver::Error::InvalidArgumentError
return emulate_click if attaching_file? && visible_file_field?
raise
end
private
def visible... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/extensions/find.rb | lib/capybara/selenium/extensions/find.rb | # frozen_string_literal: true
module Capybara
module Selenium
module Find
def find_xpath(selector, uses_visibility: false, styles: nil, position: false, **_options)
find_by(:xpath, selector, uses_visibility: uses_visibility, texts: [], styles: styles, position: position)
end
def find_c... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/extensions/modifier_keys_stack.rb | lib/capybara/selenium/extensions/modifier_keys_stack.rb | # frozen_string_literal: true
class Capybara::Selenium::Node
#
# @api private
#
class ModifierKeysStack
def initialize
@stack = []
end
def include?(key)
@stack.flatten.include?(key)
end
def press(key)
@stack.last.push(key)
end
def push
@stack.push []
e... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/extensions/html5_drag.rb | lib/capybara/selenium/extensions/html5_drag.rb | # frozen_string_literal: true
class Capybara::Selenium::Node
module Html5Drag
# Implement methods to emulate HTML5 drag and drop
def drag_to(element, html5: nil, delay: 0.05, drop_modifiers: [])
drop_modifiers = Array(drop_modifiers)
driver.execute_script MOUSEDOWN_TRACKER
scroll_if_neede... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/extensions/scroll.rb | lib/capybara/selenium/extensions/scroll.rb | # frozen_string_literal: true
module Capybara
module Selenium
module Scroll
def scroll_by(x, y)
driver.execute_script <<~JS, self, x, y
var el = arguments[0];
if (el.scrollBy){
el.scrollBy(arguments[1], arguments[2]);
} else {
el.scrollTop = el.... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb | lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb | # frozen_string_literal: true
require 'capybara/selenium/nodes/ie_node'
module Capybara::Selenium::Driver::InternetExplorerDriver
def switch_to_frame(frame)
return super unless frame == :parent
# iedriverserver has an issue if the current frame is removed from within it
# so we have to move to the defa... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/driver_specializations/safari_driver.rb | lib/capybara/selenium/driver_specializations/safari_driver.rb | # frozen_string_literal: true
require 'capybara/selenium/nodes/safari_node'
module Capybara::Selenium::Driver::SafariDriver
def switch_to_frame(frame)
return super unless frame == :parent
# safaridriver/safari has an issue where switch_to_frame(:parent)
# behaves like switch_to_frame(:top)
handles ... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/driver_specializations/chrome_driver.rb | lib/capybara/selenium/driver_specializations/chrome_driver.rb | # frozen_string_literal: true
require 'capybara/selenium/nodes/chrome_node'
require 'capybara/selenium/patches/logs'
module Capybara::Selenium::Driver::ChromeDriver
def self.extended(base)
bridge = base.send(:bridge)
bridge.extend Capybara::Selenium::ChromeLogs unless bridge.respond_to?(:log)
bridge.ext... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/driver_specializations/firefox_driver.rb | lib/capybara/selenium/driver_specializations/firefox_driver.rb | # frozen_string_literal: true
require 'capybara/selenium/nodes/firefox_node'
module Capybara::Selenium::Driver::FirefoxDriver
def self.extended(driver)
driver.extend Capybara::Selenium::Driver::W3CFirefoxDriver
bridge = driver.send(:bridge)
bridge.extend Capybara::Selenium::IsDisplayed unless bridge.sen... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/driver_specializations/edge_driver.rb | lib/capybara/selenium/driver_specializations/edge_driver.rb | # frozen_string_literal: true
require 'capybara/selenium/nodes/edge_node'
module Capybara::Selenium::Driver::EdgeDriver
def self.extended(base)
bridge = base.send(:bridge)
bridge.extend Capybara::Selenium::IsDisplayed unless bridge.send(:commands, :is_element_displayed)
base.options[:native_displayed] =... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/patches/atoms.rb | lib/capybara/selenium/patches/atoms.rb | # frozen_string_literal: true
module CapybaraAtoms
private
def read_atom(function)
@atoms ||= Hash.new do |hash, key|
hash[key] = begin
File.read(File.expand_path("../../atoms/#{key}.min.js", __FILE__))
rescue Errno::ENOENT
super
end
end
@atoms[function]
end
end
Sele... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/patches/is_displayed.rb | lib/capybara/selenium/patches/is_displayed.rb | # frozen_string_literal: true
module Capybara
module Selenium
module IsDisplayed
def commands(command)
case command
when :is_element_displayed
[:get, 'session/:session_id/element/:id/displayed']
else
super
end
end
end
end
end
| ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/patches/logs.rb | lib/capybara/selenium/patches/logs.rb | # frozen_string_literal: true
module Capybara
module Selenium
module ChromeLogs
LOG_MSG = <<~MSG
Chromedriver 75+ defaults to W3C mode. Please upgrade to chromedriver >= \
75.0.3770.90 if you need to access logs while in W3C compliant mode.
MSG
COMMANDS = {
get_availabl... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/patches/pause_duration_fix.rb | lib/capybara/selenium/patches/pause_duration_fix.rb | # frozen_string_literal: true
module PauseDurationFix
def encode
super.tap { |output| output[:duration] ||= 0 }
end
end
Selenium::WebDriver::Interactions::Pause.prepend PauseDurationFix
| ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selenium/patches/persistent_client.rb | lib/capybara/selenium/patches/persistent_client.rb | # frozen_string_literal: true
module Capybara
module Selenium
class PersistentClient < ::Selenium::WebDriver::Remote::Http::Default
def close
super
@http.finish if @http&.started?
end
private
def http
super.tap do |http|
http.start unless http.started?
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/node/actions.rb | lib/capybara/node/actions.rb | # frozen_string_literal: true
module Capybara
module Node
module Actions
# @!macro waiting_behavior
# If the driver is capable of executing JavaScript, this method will wait for a set amount of time
# and continuously retry finding the element until either the element is found or the time
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/node/element.rb | lib/capybara/node/element.rb | # frozen_string_literal: true
module Capybara
module Node
##
#
# A {Capybara::Node::Element} represents a single element on the page. It is possible
# to interact with the contents of this element the same as with a document:
#
# session = Capybara::Session.new(:rack_test, my_app)
#
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/node/matchers.rb | lib/capybara/node/matchers.rb | # frozen_string_literal: true
module Capybara
module Node
module Matchers
##
#
# Checks if a given selector is on the page or a descendant of the current node.
#
# page.has_selector?('p#foo')
# page.has_selector?(:xpath, './/p[@id="foo"]')
# page.has_selector... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | true |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/node/finders.rb | lib/capybara/node/finders.rb | # frozen_string_literal: true
module Capybara
module Node
module Finders
##
#
# Find an {Capybara::Node::Element} based on the given arguments. {#find} will raise an error if the element
# is not found.
#
# page.find('#foo').find('.bar')
# page.find(:xpath, './/d... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/node/whitespace_normalizer.rb | lib/capybara/node/whitespace_normalizer.rb | # frozen_string_literal: true
module Capybara
module Node
##
#
# {Capybara::Node::WhitespaceNormalizer} provides methods that
# help to normalize the spacing of text content inside of
# {Capybara::Node::Element}s by removing various unicode
# spacing and directional markings.
#
module... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/node/base.rb | lib/capybara/node/base.rb | # frozen_string_literal: true
module Capybara
module Node
##
#
# A {Capybara::Node::Base} represents either an element on a page through the subclass
# {Capybara::Node::Element} or a document through {Capybara::Node::Document}.
#
# Both types of Node share the same methods, used for interacti... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/node/simple.rb | lib/capybara/node/simple.rb | # frozen_string_literal: true
module Capybara
module Node
##
#
# A {Capybara::Node::Simple} is a simpler version of {Capybara::Node::Base} which
# includes only {Capybara::Node::Finders} and {Capybara::Node::Matchers} and does
# not include {Capybara::Node::Actions}. This type of node is returned... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/node/document_matchers.rb | lib/capybara/node/document_matchers.rb | # frozen_string_literal: true
module Capybara
module Node
module DocumentMatchers
##
# Asserts that the page has the given title.
#
# @!macro title_query_params
# @overload $0(string, **options)
# @param string [String] The string that title should include
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/node/document.rb | lib/capybara/node/document.rb | # frozen_string_literal: true
module Capybara
module Node
##
#
# A {Capybara::Document} represents an HTML document. Any operation
# performed on it will be performed on the entire document.
#
# @see Capybara::Node
#
class Document < Base
include Capybara::Node::DocumentMatchers... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/registrations/servers.rb | lib/capybara/registrations/servers.rb | # frozen_string_literal: true
Capybara.register_server :default do |app, port, _host|
Capybara.run_default_server(app, port)
end
Capybara.register_server :webrick do |app, port, host, **options|
base_class = begin
require 'rack/handler/webrick'
Rack
rescue LoadError
# Rack 3 separated out the webric... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/registrations/drivers.rb | lib/capybara/registrations/drivers.rb | # frozen_string_literal: true
Capybara.register_driver :rack_test do |app|
Capybara::RackTest::Driver.new(app)
end
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app)
end
Capybara.register_driver :selenium_headless do |app|
version = Capybara::Selenium::Driver.load_selenium
option... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/registrations/patches/puma_ssl.rb | lib/capybara/registrations/patches/puma_ssl.rb | # frozen_string_literal: true
module Puma
module MiniSSL
class Socket
def read_nonblock(size, *_)
wait_states = %i[wait_readable wait_writable]
loop do
output = engine_read_all
return output if output
data = @socket.read_nonblock(size, exception: false)
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/selector.rb | lib/capybara/selector/selector.rb | # frozen_string_literal: true
module Capybara
class Selector < SimpleDelegator
class << self
def all
@definitions ||= {} # rubocop:disable Naming/MemoizedInstanceVariableName
end
def [](name)
all.fetch(name.to_sym) { |sel_type| raise ArgumentError, "Unknown selector type (:#{se... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/css.rb | lib/capybara/selector/css.rb | # frozen_string_literal: true
require 'capybara/selector/selector'
module Capybara
class Selector
class CSS
def self.escape(str)
value = str.dup
out = +''
out << value.slice!(0...1) if value.match?(/^[-_]/)
out << (value[0].match?(NMSTART) ? value.slice!(0...1) : escape_cha... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/filter.rb | lib/capybara/selector/filter.rb | # frozen_string_literal: true
require 'capybara/selector/filters/node_filter'
require 'capybara/selector/filters/expression_filter'
require 'capybara/selector/filters/locator_filter'
| ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition.rb | lib/capybara/selector/definition.rb | # frozen_string_literal: true
require 'capybara/selector/filter_set'
require 'capybara/selector/css'
require 'capybara/selector/regexp_disassembler'
require 'capybara/selector/builders/xpath_builder'
require 'capybara/selector/builders/css_builder'
module Capybara
class Selector
class Definition
attr_read... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/filter_set.rb | lib/capybara/selector/filter_set.rb | # frozen_string_literal: true
require 'capybara/selector/filter'
module Capybara
class Selector
class FilterSet
attr_reader :node_filters, :expression_filters
def initialize(name, &block)
@name = name
@node_filters = {}
@expression_filters = {}
@descriptions = Hash.n... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/xpath_extensions.rb | lib/capybara/selector/xpath_extensions.rb | # frozen_string_literal: true
module XPath
class Renderer
def join(*expressions)
expressions.join('/')
end
end
end
module XPath
module DSL
def join(*expressions)
XPath::Expression.new(:join, *[self, expressions].flatten)
end
end
end
| ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/regexp_disassembler.rb | lib/capybara/selector/regexp_disassembler.rb | # frozen_string_literal: true
require 'regexp_parser'
module Capybara
class Selector
# @api private
class RegexpDisassembler
def initialize(regexp)
@regexp = regexp
end
def alternated_substrings
@alternated_substrings ||= begin
or_strings = process(alternation: t... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/datalist_option.rb | lib/capybara/selector/definition/datalist_option.rb | # frozen_string_literal: true
Capybara.add_selector(:datalist_option, locator_type: [String, Symbol]) do
label 'datalist option'
visible(:all)
xpath do |locator|
xpath = XPath.descendant(:option)
xpath = xpath[XPath.string.n.is(locator.to_s) | (XPath.attr(:value) == locator.to_s)] unless locator.nil?
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/link_or_button.rb | lib/capybara/selector/definition/link_or_button.rb | # frozen_string_literal: true
Capybara.add_selector(:link_or_button, locator_type: [String, Symbol]) do
label 'link or button'
xpath do |locator, **options|
%i[link button].map do |selector|
expression_for(selector, locator, **options)
end.reduce(:union)
end
node_filter(:disabled, :boolean, defa... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/element.rb | lib/capybara/selector/definition/element.rb | # frozen_string_literal: true
Capybara.add_selector(:element, locator_type: [String, Symbol]) do
xpath do |locator, **|
XPath.descendant.where(locator ? XPath.local_name == locator.to_s : nil)
end
expression_filter(:attributes, matcher: /.+/) do |xpath, name, val|
builder(xpath).add_attribute_conditions... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/table.rb | lib/capybara/selector/definition/table.rb | # frozen_string_literal: true
Capybara.add_selector(:table, locator_type: [String, Symbol]) do
xpath do |locator, caption: nil, **|
xpath = XPath.descendant(:table)
unless locator.nil?
locator_matchers = (XPath.attr(:id) == locator.to_s) | XPath.descendant(:caption).is(locator.to_s)
locator_match... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/xpath.rb | lib/capybara/selector/definition/xpath.rb | # frozen_string_literal: true
Capybara.add_selector(:xpath, locator_type: [:to_xpath, String], raw_locator: true) do
xpath { |xpath| xpath }
end
| ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/fieldset.rb | lib/capybara/selector/definition/fieldset.rb | # frozen_string_literal: true
Capybara.add_selector(:fieldset, locator_type: [String, Symbol]) do
xpath do |locator, legend: nil, **|
locator_matchers = (XPath.attr(:id) == locator.to_s) | XPath.child(:legend)[XPath.string.n.is(locator.to_s)]
locator_matchers |= XPath.attr(test_id) == locator.to_s if test_id... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/css.rb | lib/capybara/selector/definition/css.rb | # frozen_string_literal: true
Capybara.add_selector(:css, locator_type: [String, Symbol], raw_locator: true) do
css do |css|
if css.is_a? Symbol
Capybara::Helpers.warn "DEPRECATED: Passing a symbol (#{css.inspect}) as the CSS locator is deprecated - please pass a string instead : #{Capybara::Helpers.filter... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/id.rb | lib/capybara/selector/definition/id.rb | # frozen_string_literal: true
Capybara.add_selector(:id, locator_type: [String, Symbol, Regexp]) do
xpath { |id| builder(XPath.descendant).add_attribute_conditions(id: id) }
locator_filter { |node, id| id.is_a?(Regexp) ? id.match?(node[:id]) : true }
end
| ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/select.rb | lib/capybara/selector/definition/select.rb | # frozen_string_literal: true
Capybara.add_selector(:select, locator_type: [String, Symbol]) do
label 'select box'
xpath do |locator, **options|
xpath = XPath.descendant(:select)
locate_field(xpath, locator, **options)
end
filter_set(:_field, %i[disabled multiple name placeholder])
node_filter(:op... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/frame.rb | lib/capybara/selector/definition/frame.rb | # frozen_string_literal: true
Capybara.add_selector(:frame, locator_type: [String, Symbol]) do
xpath do |locator, name: nil, **|
xpath = XPath.descendant(:iframe).union(XPath.descendant(:frame))
unless locator.nil?
locator_matchers = (XPath.attr(:id) == locator.to_s) | (XPath.attr(:name) == locator.to_... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/field.rb | lib/capybara/selector/definition/field.rb | # frozen_string_literal: true
Capybara.add_selector(:field, locator_type: [String, Symbol]) do
visible { |options| :hidden if options[:type].to_s == 'hidden' }
xpath do |locator, **options|
invalid_types = %w[submit image]
invalid_types << 'hidden' unless options[:type].to_s == 'hidden'
xpath = XPath.... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/radio_button.rb | lib/capybara/selector/definition/radio_button.rb | # frozen_string_literal: true
Capybara.add_selector(:radio_button, locator_type: [String, Symbol]) do
label 'radio button'
xpath do |locator, allow_self: nil, **options|
xpath = XPath.axis(allow_self ? :'descendant-or-self' : :descendant, :input)[
XPath.attr(:type) == 'radio'
]
locate_field(xpath... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/button.rb | lib/capybara/selector/definition/button.rb | # frozen_string_literal: true
Capybara.add_selector(:button, locator_type: [String, Symbol]) do
xpath(:value, :title, :type, :name) do |locator, **options|
input_btn_xpath = XPath.descendant(:input)[XPath.attr(:type).one_of('submit', 'reset', 'image', 'button')]
btn_xpath = XPath.descendant(:button)
aria... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/link.rb | lib/capybara/selector/definition/link.rb | # frozen_string_literal: true
Capybara.add_selector(:link, locator_type: [String, Symbol]) do
xpath do |locator, href: true, alt: nil, title: nil, target: nil, **|
xpath = XPath.descendant(:a)
xpath = builder(xpath).add_attribute_conditions(href: href) unless href == false
if enable_aria_role
role... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/datalist_input.rb | lib/capybara/selector/definition/datalist_input.rb | # frozen_string_literal: true
Capybara.add_selector(:datalist_input, locator_type: [String, Symbol]) do
label 'input box with datalist completion'
xpath do |locator, **options|
xpath = XPath.descendant(:input)[XPath.attr(:list)]
locate_field(xpath, locator, **options)
end
filter_set(:_field, %i[disab... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/table_row.rb | lib/capybara/selector/definition/table_row.rb | # frozen_string_literal: true
Capybara.add_selector(:table_row, locator_type: [Array, Hash]) do
xpath do |locator|
xpath = XPath.descendant(:tr)
if locator.is_a? Hash
locator.reduce(xpath) do |xp, (header, cell)|
header_xp = XPath.ancestor(:table)[1].descendant(:tr)[1].descendant(:th)[XPath.str... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/fillable_field.rb | lib/capybara/selector/definition/fillable_field.rb | # frozen_string_literal: true
Capybara.add_selector(:fillable_field, locator_type: [String, Symbol]) do
label 'field'
xpath do |locator, allow_self: nil, **options|
xpath = XPath.axis(allow_self ? :'descendant-or-self' : :descendant, :input, :textarea)[
!XPath.attr(:type).one_of('submit', 'image', 'radio... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/option.rb | lib/capybara/selector/definition/option.rb | # frozen_string_literal: true
Capybara.add_selector(:option, locator_type: [String, Symbol, Integer]) do
xpath do |locator|
xpath = XPath.descendant(:option)
xpath = xpath[XPath.string.n.is(locator.to_s)] unless locator.nil?
xpath
end
node_filter(:disabled, :boolean) { |node, value| !(value ^ node.d... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/file_field.rb | lib/capybara/selector/definition/file_field.rb | # frozen_string_literal: true
Capybara.add_selector(:file_field, locator_type: [String, Symbol]) do
label 'file field'
xpath do |locator, allow_self: nil, **options|
xpath = XPath.axis(allow_self ? :'descendant-or-self' : :descendant, :input)[
XPath.attr(:type) == 'file'
]
locate_field(xpath, loc... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/checkbox.rb | lib/capybara/selector/definition/checkbox.rb | # frozen_string_literal: true
Capybara.add_selector(:checkbox, locator_type: [String, Symbol]) do
xpath do |locator, allow_self: nil, **options|
xpath = XPath.axis(allow_self ? :'descendant-or-self' : :descendant, :input)[
XPath.attr(:type) == 'checkbox'
]
locate_field(xpath, locator, **options)
... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/definition/label.rb | lib/capybara/selector/definition/label.rb | # frozen_string_literal: true
Capybara.add_selector(:label, locator_type: [String, Symbol]) do
label 'label'
xpath(:for) do |locator, **options|
xpath = XPath.descendant(:label)
unless locator.nil?
locator_matchers = XPath.string.n.is(locator.to_s) | (XPath.attr(:id) == locator.to_s)
locator_ma... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
teamcapybara/capybara | https://github.com/teamcapybara/capybara/blob/b3325b198464b806f07ec2011ceb532d6d5cf4ab/lib/capybara/selector/filters/expression_filter.rb | lib/capybara/selector/filters/expression_filter.rb | # frozen_string_literal: true
require 'capybara/selector/filters/base'
module Capybara
class Selector
module Filters
class ExpressionFilter < Base
def apply_filter(expr, name, value, selector)
apply(expr, name, value, expr, selector)
end
end
class IdentityExpressionF... | ruby | MIT | b3325b198464b806f07ec2011ceb532d6d5cf4ab | 2026-01-04T15:38:10.098638Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.