function_name
stringlengths
2
43
file_path
stringlengths
20
71
focal_code
stringlengths
176
2.2k
file_content
stringlengths
428
89.7k
language
stringclasses
1 value
function_component
dict
metadata
dict
using_session
capybara/lib/capybara.rb
def using_session(name_or_session, &block) previous_session = current_session previous_session_info = { specified_session: specified_session, session_name: session_name, current_driver: current_driver, app: app } self.specified_session = self.session_name = nil ...
# 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
{ "end_line": 381, "name": "using_session", "signature": "def using_session(name_or_session, &block)", "start_line": 358 }
{ "class_name": "", "class_signature": "", "module": "Capybara" }
HTML
capybara/lib/capybara.rb
def HTML(html) # rubocop:disable Naming/MethodName # Nokogiri >= 1.12.0 or Nokogumbo installed and allowed for use html_parser, using_html5 = if defined?(Nokogiri::HTML5) && Capybara.use_html5_parsing [Nokogiri::HTML5, true] else [defined?(Nokogiri::HTML4) ? Nokogiri::HTML4 : Nokogiri:...
# 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
{ "end_line": 408, "name": "HTML", "signature": "def HTML(html) # rubocop:disable Naming/MethodName", "start_line": 390 }
{ "class_name": "", "class_signature": "", "module": "Capybara" }
server=
capybara/lib/capybara/config.rb
def server=(name) name, options = *name if name.is_a? Array @server = if name.respond_to? :call name elsif options proc { |app, port, host| Capybara.servers[name.to_sym].call(app, port, host, **options) } else Capybara.servers[name.to_sym] end end
# 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
{ "end_line": 68, "name": "server=", "signature": "def server=(name)", "start_line": 59 }
{ "class_name": "Config", "class_signature": "class Config", "module": "Capybara" }
each
capybara/lib/capybara/result.rb
def each(&block) return enum_for(:each) unless block @result_cache.each(&block) loop do next_result = @results_enum.next add_to_cache(next_result) yield next_result end self end
# 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
{ "end_line": 51, "name": "each", "signature": "def each(&block)", "start_line": 41 }
{ "class_name": "Result", "class_signature": "class Result", "module": "Capybara" }
[]
capybara/lib/capybara/result.rb
def [](*args) idx, length = args max_idx = case idx when Integer if idx.negative? nil else length.nil? ? idx : idx + length - 1 end when Range # idx.max is broken with beginless ranges # idx.end && idx.max # endless range will have end ...
# 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
{ "end_line": 77, "name": "[]", "signature": "def [](*args)", "start_line": 53 }
{ "class_name": "Result", "class_signature": "class Result", "module": "Capybara" }
compare_count
capybara/lib/capybara/result.rb
def compare_count return 0 unless @query count, min, max, between = @query.options.values_at(:count, :minimum, :maximum, :between) # Only check filters for as many elements as necessary to determine result if count && (count = Integer(count)) return load_up_to(count + 1) <=> count ...
# 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
{ "end_line": 107, "name": "compare_count", "signature": "def compare_count", "start_line": 84 }
{ "class_name": "Result", "class_signature": "class Result", "module": "Capybara" }
failure_message
capybara/lib/capybara/result.rb
def failure_message message = @query.failure_message if count.zero? message << ' but there were no matches' else message << ", found #{count} #{Capybara::Helpers.declension('match', 'matches', count)}: " \ << full_results.map { |r| r.text.inspect }.join(', ') end ...
# 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
{ "end_line": 127, "name": "failure_message", "signature": "def failure_message", "start_line": 113 }
{ "class_name": "Result", "class_signature": "class Result", "module": "Capybara" }
initialize
capybara/lib/capybara/server.rb
def initialize(app, *deprecated_options, port: Capybara.server_port, host: Capybara.server_host, reportable_errors: Capybara.server_errors, extra_middleware: []) unless deprecated_options.empty? warn 'Positional...
# 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
{ "end_line": 39, "name": "initialize", "signature": "def initialize(app,", "start_line": 21 }
{ "class_name": "Server", "class_signature": "class Server", "module": "Capybara" }
boot
capybara/lib/capybara/server.rb
def boot unless responsive? Capybara::Server.ports[port_key] = port @server_thread = Thread.new do Capybara.server.call(middleware, port, host) end timer = Capybara::Helpers.timer(expire_in: 60) until responsive? raise 'Rack application timed out durin...
# 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
{ "end_line": 89, "name": "boot", "signature": "def boot", "start_line": 72 }
{ "class_name": "Server", "class_signature": "class Server", "module": "Capybara" }
find_available_port
capybara/lib/capybara/server.rb
def find_available_port(host) server = TCPServer.new(host, 0) port = server.addr[1] server.close # Workaround issue where some platforms (mac, ???) when passed a host # of '0.0.0.0' will return a port that is only available on one of the # ip addresses that resolves to, but the next...
# 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
{ "end_line": 124, "name": "find_available_port", "signature": "def find_available_port(host)", "start_line": 109 }
{ "class_name": "Server", "class_signature": "class Server", "module": "Capybara" }
initialize
capybara/lib/capybara/session.rb
def initialize(mode, app = nil) if app && !app.respond_to?(:call) raise TypeError, 'The second parameter to Session::new should be a rack app if passed.' end @@instance_created = true # rubocop:disable Style/ClassVars @mode = mode @app = app if block_given? raise 'A ...
# 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
{ "end_line": 98, "name": "initialize", "signature": "def initialize(mode, app = nil)", "start_line": 79 }
{ "class_name": "Session", "class_signature": "class Session", "module": "Capybara" }
driver
capybara/lib/capybara/session.rb
def driver @driver ||= begin unless Capybara.drivers[mode] other_drivers = Capybara.drivers.names.map(&:inspect) raise Capybara::DriverNotFoundError, "no driver called #{mode.inspect} was found, available drivers: #{other_drivers.join(', ')}" end driver = Capybara.drive...
# 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
{ "end_line": 110, "name": "driver", "signature": "def driver", "start_line": 100 }
{ "class_name": "Session", "class_signature": "class Session", "module": "Capybara" }
reset!
capybara/lib/capybara/session.rb
def reset! if @touched driver.reset! @touched = false switch_to_frame(:top) rescue nil # rubocop:disable Style/RescueModifier @scopes = [nil] end @server&.wait_for_pending_requests raise_server_error! end
# 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
{ "end_line": 139, "name": "reset!", "signature": "def reset!", "start_line": 130 }
{ "class_name": "Session", "class_signature": "class Session", "module": "Capybara" }
raise_server_error!
capybara/lib/capybara/session.rb
def raise_server_error! return unless @server&.error # Force an explanation for the error being raised as the exception cause begin if config.raise_server_errors raise CapybaraError, 'Your application server raised an error - It has been raised in your test code because Capybara.rai...
# 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
{ "end_line": 171, "name": "raise_server_error!", "signature": "def raise_server_error!", "start_line": 158 }
{ "class_name": "Session", "class_signature": "class Session", "module": "Capybara" }
visit
capybara/lib/capybara/session.rb
def visit(visit_uri) raise_server_error! @touched = true visit_uri = ::Addressable::URI.parse(visit_uri.to_s) base_uri = ::Addressable::URI.parse(config.app_host || server_url) if base_uri && [nil, 'http', 'https'].include?(visit_uri.scheme) if visit_uri.relative? visit...
# 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
{ "end_line": 282, "name": "visit", "signature": "def visit(visit_uri)", "start_line": 261 }
{ "class_name": "Session", "class_signature": "class Session", "module": "Capybara" }
switch_to_frame
capybara/lib/capybara/session.rb
def switch_to_frame(frame) case frame when Capybara::Node::Element driver.switch_to_frame(frame) scopes.push(:frame) when :parent if scopes.last != :frame raise Capybara::ScopeError, "`switch_to_frame(:parent)` cannot be called from inside a descendant frame's " \ ...
# 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
{ "end_line": 434, "name": "switch_to_frame", "signature": "def switch_to_frame(frame)", "start_line": 408 }
{ "class_name": "Session", "class_signature": "class Session", "module": "Capybara" }
within_window
capybara/lib/capybara/session.rb
def within_window(window_or_proc) original = current_window scopes << nil begin case window_or_proc when Capybara::Window _switch_to_window(window_or_proc) unless original == window_or_proc when Proc _switch_to_window { window_or_proc.call } else ...
# 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
{ "end_line": 566, "name": "within_window", "signature": "def within_window(window_or_proc)", "start_line": 545 }
{ "class_name": "Session", "class_signature": "class Session", "module": "Capybara" }
window_opened_by
capybara/lib/capybara/session.rb
def window_opened_by(**options) old_handles = driver.window_handles yield synchronize_windows(options) do opened_handles = (driver.window_handles - old_handles) if opened_handles.size != 1 raise Capybara::WindowError, 'block passed to #window_opened_by ' \ ...
# 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
{ "end_line": 593, "name": "window_opened_by", "signature": "def window_opened_by(**options)", "start_line": 581 }
{ "class_name": "Session", "class_signature": "class Session", "module": "Capybara" }
using_wait_time
capybara/lib/capybara/session.rb
def using_wait_time(seconds, &block) if Capybara.threadsafe begin previous_wait_time = config.default_max_wait_time config.default_max_wait_time = seconds yield ensure config.default_max_wait_time = previous_wait_time end else Capybara....
# 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
{ "end_line": 812, "name": "using_wait_time", "signature": "def using_wait_time(seconds, &block)", "start_line": 800 }
{ "class_name": "Session", "class_signature": "class Session", "module": "Capybara" }
element_script_result
capybara/lib/capybara/session.rb
def element_script_result(arg) case arg when Array arg.map { |subarg| element_script_result(subarg) } when Hash arg.transform_values! { |value| element_script_result(value) } when Capybara::Driver::Node Capybara::Node::Element.new(self, arg, nil, nil) else a...
# 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
{ "end_line": 896, "name": "element_script_result", "signature": "def element_script_result(arg)", "start_line": 885 }
{ "class_name": "Session", "class_signature": "class Session", "module": "Capybara" }
wait_for_stable_size
capybara/lib/capybara/window.rb
def wait_for_stable_size(seconds = session.config.default_max_wait_time) res = yield if block_given? timer = Capybara::Helpers.timer(expire_in: seconds) loop do prev_size = size sleep 0.025 return res if prev_size == size break if timer.expired? end raise Ca...
# 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
{ "end_line": 140, "name": "wait_for_stable_size", "signature": "def wait_for_stable_size(seconds = session.config.default_max_wait_time)", "start_line": 130 }
{ "class_name": "Window", "class_signature": "class Window", "module": "Capybara" }
attach_file
capybara/lib/capybara/node/actions.rb
def attach_file(locator = nil, paths, make_visible: nil, **options) # rubocop:disable Style/OptionalArguments if locator && block_given? raise ArgumentError, '`#attach_file` does not support passing both a locator and a block' end Array(paths).each do |path| raise Capybara::...
# 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
{ "end_line": 306, "name": "attach_file", "signature": "def attach_file(locator = nil, paths, make_visible: nil, **options) # rubocop:disable Style/OptionalArguments", "start_line": 279 }
{ "class_name": "", "class_signature": "", "module": "Capybara" }
find_select_or_datalist_input
capybara/lib/capybara/node/actions.rb
def find_select_or_datalist_input(from, options) synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do find(:select, from, **options) rescue Capybara::ElementNotFound => select_error # rubocop:disable Naming/RescuedExceptionsVariableName ra...
# 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
{ "end_line": 322, "name": "find_select_or_datalist_input", "signature": "def find_select_or_datalist_input(from, options)", "start_line": 310 }
{ "class_name": "", "class_signature": "", "module": "Capybara" }
select_datalist_option
capybara/lib/capybara/node/actions.rb
def select_datalist_option(input, value) datalist_options = input.evaluate_script(DATALIST_OPTIONS_SCRIPT) option = datalist_options.find { |opt| opt.values_at('value', 'label').include?(value) } raise ::Capybara::ElementNotFound, %(Unable to find datalist option "#{value}") unless option ...
# 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
{ "end_line": 335, "name": "select_datalist_option", "signature": "def select_datalist_option(input, value)", "start_line": 324 }
{ "class_name": "", "class_signature": "", "module": "Capybara" }
while_visible
capybara/lib/capybara/node/actions.rb
def while_visible(element, visible_css) if visible_css == true visible_css = { opacity: 1, display: 'block', visibility: 'visible', width: 'auto', height: 'auto' } end _update_style(element, visible_css) unless element.visible? raise ExpectationNotMet, 'The style chan...
# 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
{ "end_line": 351, "name": "while_visible", "signature": "def while_visible(element, visible_css)", "start_line": 337 }
{ "class_name": "", "class_signature": "", "module": "Capybara" }
synchronize
capybara/lib/capybara/node/base.rb
def synchronize(seconds = nil, errors: nil) return yield if session.synchronized seconds = session_options.default_max_wait_time if [nil, true].include? seconds interval = session_options.default_retry_interval session.synchronized = true timer = Capybara::Helpers.timer(expire_i...
# 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
{ "end_line": 103, "name": "synchronize", "signature": "def synchronize(seconds = nil, errors: nil)", "start_line": 76 }
{ "class_name": "Base", "class_signature": "class Base", "module": "Capybara" }
style
capybara/lib/capybara/node/element.rb
def style(*styles) styles = styles.flatten.map(&:to_s) raise ArgumentError, 'You must specify at least one CSS style' if styles.empty? begin synchronize { base.style(styles) } rescue NotImplementedError => e begin evaluate_script(STYLE_SCRIPT, *styles) ...
# 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
{ "end_line": 99, "name": "style", "signature": "def style(*styles)", "start_line": 86 }
{ "class_name": "Element", "class_signature": "class Element < < Base", "module": "Capybara" }
scroll_to
capybara/lib/capybara/node/element.rb
def scroll_to(pos_or_el_or_x, y = nil, align: :top, offset: nil) case pos_or_el_or_x when Symbol synchronize { base.scroll_to(nil, pos_or_el_or_x) } unless pos_or_el_or_x == :current when Capybara::Node::Element synchronize { base.scroll_to(pos_or_el_or_x.base, align) } ...
# 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
{ "end_line": 473, "name": "scroll_to", "signature": "def scroll_to(pos_or_el_or_x, y = nil, align: :top, offset: nil)", "start_line": 462 }
{ "class_name": "Element", "class_signature": "class Element < < Base", "module": "Capybara" }
flash
capybara/lib/capybara/node/element.rb
def flash execute_script(<<~JS, 100) async function flash(el, delay){ var old_bg = el.style.backgroundColor; var colors = ["black", "white"]; for(var i=0; i<20; i++){ el.style.backgroundColor = colors[i % colors.length]; await new Promise...
# 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
{ "end_line": 557, "name": "flash", "signature": "def flash", "start_line": 542 }
{ "class_name": "Element", "class_signature": "class Element < < Base", "module": "Capybara" }
reload
capybara/lib/capybara/node/element.rb
def reload return self unless @allow_reload begin reloaded = @query.resolve_for(query_scope ? query_scope.reload : session)[@query_idx.to_i] @base = reloaded.base if reloaded rescue StandardError => e raise e unless catch_error?(e) end self en...
# 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
{ "end_line": 570, "name": "reload", "signature": "def reload", "start_line": 560 }
{ "class_name": "Element", "class_signature": "class Element < < Base", "module": "Capybara" }
find
capybara/lib/capybara/node/finders.rb
def find(*args, **options, &optional_filter_block) options[:session_options] = session_options count_options = options.slice(*Capybara::Queries::BaseQuery::COUNT_KEYS) unless count_options.empty? Capybara::Helpers.warn( "'find' does not support count options (#{count_option...
# 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
{ "end_line": 61, "name": "find", "signature": "def find(*args, **options, &optional_filter_block)", "start_line": 51 }
{ "class_name": "", "class_signature": "", "module": "Capybara" }
all
capybara/lib/capybara/node/finders.rb
def all(*args, allow_reload: false, **options, &optional_filter_block) minimum_specified = options_include_minimum?(options) options = { minimum: 1 }.merge(options) unless minimum_specified options[:session_options] = session_options query = Capybara::Queries::SelectorQuery.new(*args, **...
# 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
{ "end_line": 276, "name": "all", "signature": "def all(*args, allow_reload: false, **options, &optional_filter_block)", "start_line": 257 }
{ "class_name": "", "class_signature": "", "module": "Capybara" }
synced_resolve
capybara/lib/capybara/node/finders.rb
def synced_resolve(query) synchronize(query.wait) do if prefer_exact?(query) result = query.resolve_for(self, true) result = query.resolve_for(self, false) if result.empty? && query.supports_exact? && !query.exact? else result = query.resolve_for(self) ...
# 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
{ "end_line": 316, "name": "synced_resolve", "signature": "def synced_resolve(query)", "start_line": 300 }
{ "class_name": "", "class_signature": "", "module": "Capybara" }
assert_any_of_selectors
capybara/lib/capybara/node/matchers.rb
def assert_any_of_selectors(*args, wait: nil, **options, &optional_filter_block) wait = session_options.default_max_wait_time if wait.nil? selector = extract_selector(args) synchronize(wait) do res = args.map do |locator| assert_selector(selector, locator, options, &optiona...
# 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
{ "end_line": 215, "name": "assert_any_of_selectors", "signature": "def assert_any_of_selectors(*args, wait: nil, **options, &optional_filter_block)", "start_line": 201 }
{ "class_name": "", "class_signature": "", "module": "Capybara" }
[]
capybara/lib/capybara/node/simple.rb
def [](name) attr_name = name.to_s if attr_name == 'value' value elsif (tag_name == 'input') && (native[:type] == 'checkbox') && (attr_name == 'checked') native['checked'] == 'checked' else native[attr_name] end end
# 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
{ "end_line": 54, "name": "[]", "signature": "def [](name)", "start_line": 45 }
{ "class_name": "Simple", "class_signature": "class Simple", "module": "Capybara" }
value
capybara/lib/capybara/node/simple.rb
def value if tag_name == 'textarea' native['_capybara_raw_value'] elsif tag_name == 'select' selected_options = find_xpath('.//option[@selected]') if multiple? selected_options.map(&method(:option_value)) else option_value(selected_options....
# 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
{ "end_line": 93, "name": "value", "signature": "def value", "start_line": 78 }
{ "class_name": "Simple", "class_signature": "class Simple", "module": "Capybara" }
visible?
capybara/lib/capybara/node/simple.rb
def visible?(check_ancestors = true) # rubocop:disable Style/OptionalBooleanParameter return false if (tag_name == 'input') && (native[:type] == 'hidden') return false if tag_name == 'template' if check_ancestors !find_xpath(VISIBILITY_XPATH) else # No need for an xp...
# 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
{ "end_line": 115, "name": "visible?", "signature": "def visible?(check_ancestors = true) # rubocop:disable Style/OptionalBooleanParameter", "start_line": 103 }
{ "class_name": "Simple", "class_signature": "class Simple", "module": "Capybara" }
resolve_for
capybara/lib/capybara/queries/ancestor_query.rb
def resolve_for(node, exact = nil) @child_node = node node.synchronize do scope = node.respond_to?(:session) ? node.session.current_scope : node.find(:xpath, '/*') match_results = super(scope, exact) ancestors = node.find_xpath(XPath.ancestor.to_s) ...
# frozen_string_literal: true module Capybara module Queries class AncestorQuery < Capybara::Queries::SelectorQuery # @api private def resolve_for(node, exact = nil) @child_node = node node.synchronize do scope = node.respond_to?(:session) ? node.session.current_scope : nod...
Ruby
{ "end_line": 18, "name": "resolve_for", "signature": "def resolve_for(node, exact = nil)", "start_line": 7 }
{ "class_name": "AncestorQuery", "class_signature": "class AncestorQuery < < Capybara::Queries::SelectorQuery", "module": "Capybara" }
count_message
capybara/lib/capybara/queries/base_query.rb
def count_message message = +'' count, between, maximum, minimum = options.values_at(:count, :between, :maximum, :minimum) if count message << " #{occurrences count}" elsif between message << " between #{between.begin ? between.first : 1} and " \ ...
# frozen_string_literal: true module Capybara # @api private module Queries class BaseQuery COUNT_KEYS = %i[count minimum maximum between].freeze attr_reader :options attr_writer :session_options def initialize(options) @session_options = options.delete(:session_options) ...
Ruby
{ "end_line": 90, "name": "count_message", "signature": "def count_message", "start_line": 76 }
{ "class_name": "BaseQuery", "class_signature": "class BaseQuery", "module": "Capybara" }
initialize
capybara/lib/capybara/queries/current_path_query.rb
def initialize(expected_path, **options, &optional_filter_block) super(options) @expected_path = expected_path @options = { url: !@expected_path.is_a?(Regexp) && !::Addressable::URI.parse(@expected_path || '').hostname.nil?, ignore_query: false }.merge(options) ...
# frozen_string_literal: true require 'addressable/uri' module Capybara # @api private module Queries class CurrentPathQuery < BaseQuery def initialize(expected_path, **options, &optional_filter_block) super(options) @expected_path = expected_path @options = { url: !@ex...
Ruby
{ "end_line": 18, "name": "initialize", "signature": "def initialize(expected_path, **options, &optional_filter_block)", "start_line": 9 }
{ "class_name": "CurrentPathQuery", "class_signature": "class CurrentPathQuery < < BaseQuery", "module": "Capybara" }
resolves_for?
capybara/lib/capybara/queries/current_path_query.rb
def resolves_for?(session) uri = ::Addressable::URI.parse(session.current_url) @actual_path = (options[:ignore_query] ? uri&.omit(:query) : uri).then do |u| options[:url] ? u&.to_s : u&.request_uri end res = if @expected_path.is_a? Regexp @actual_path.to_s.match?(@ex...
# frozen_string_literal: true require 'addressable/uri' module Capybara # @api private module Queries class CurrentPathQuery < BaseQuery def initialize(expected_path, **options, &optional_filter_block) super(options) @expected_path = expected_path @options = { url: !@ex...
Ruby
{ "end_line": 33, "name": "resolves_for?", "signature": "def resolves_for?(session)", "start_line": 20 }
{ "class_name": "CurrentPathQuery", "class_signature": "class CurrentPathQuery < < BaseQuery", "module": "Capybara" }
initialize
capybara/lib/capybara/queries/selector_query.rb
def initialize(*args, session_options:, enable_aria_label: session_options.enable_aria_label, enable_aria_role: session_options.enable_aria_role, test_id: session_options.test_id, selector_format: nil, ...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 59, "name": "initialize", "signature": "def initialize(*args,", "start_line": 15 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
description
capybara/lib/capybara/queries/selector_query.rb
def description(only_applied = false) # rubocop:disable Style/OptionalBooleanParameter desc = +'' show_for = show_for_stage(only_applied) if show_for[:any] desc << 'visible ' if visible == :visible desc << 'non-visible ' if visible == :hidden end desc << lab...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 112, "name": "description", "signature": "def description(only_applied = false) # rubocop:disable Style/OptionalBooleanParameter", "start_line": 64 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
matches_filters?
capybara/lib/capybara/queries/selector_query.rb
def matches_filters?(node, node_filter_errors = []) return true if (@resolved_node&.== node) && options[:allow_self] matches_locator_filter?(node) && matches_system_filters?(node) && matches_spatial_filters?(node) && matches_node_filters?(node, node_filter_errors) && ...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 128, "name": "matches_filters?", "signature": "def matches_filters?(node, node_filter_errors = [])", "start_line": 118 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
resolve_for
capybara/lib/capybara/queries/selector_query.rb
def resolve_for(node, exact = nil) applied_filters.clear @filter_cache.clear @resolved_node = node @resolved_count += 1 node.synchronize do children = find_nodes_by_selector_format(node, exact).map(&method(:to_element)) Capybara::Result.new(ordered_results(ch...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 170, "name": "resolve_for", "signature": "def resolve_for(node, exact = nil)", "start_line": 160 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
xpath_text_conditions
capybara/lib/capybara/queries/selector_query.rb
def xpath_text_conditions case (text = matching_text) when String text.split.map { |txt| XPath.contains(txt) }.reduce(&:&) when Regexp condition = XPath.current condition = condition.uppercase if text.casefold? Selector::RegexpDisassembler.new(text).altern...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 212, "name": "xpath_text_conditions", "signature": "def xpath_text_conditions", "start_line": 201 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
find_nodes_by_selector_format
capybara/lib/capybara/queries/selector_query.rb
def find_nodes_by_selector_format(node, exact) hints = {} hints[:uses_visibility] = true unless visible == :all hints[:texts] = text_fragments unless selector_format == :xpath hints[:styles] = options[:style] if use_default_style_filter? hints[:position] = true if use_spatial_fil...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 265, "name": "find_nodes_by_selector_format", "signature": "def find_nodes_by_selector_format(node, exact)", "start_line": 242 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
matches_node_filters?
capybara/lib/capybara/queries/selector_query.rb
def matches_node_filters?(node, errors) applied_filters << :node unapplied_options = options.keys - valid_keys @selector.with_filter_errors(errors) do node_filters.all? do |filter_name, filter| next true unless apply_filter?(filter) if filter.matcher? ...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 302, "name": "matches_node_filters?", "signature": "def matches_node_filters?(node, errors)", "start_line": 279 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
assert_valid_keys
capybara/lib/capybara/queries/selector_query.rb
def assert_valid_keys unless VALID_MATCH.include?(match) raise ArgumentError, "Invalid option #{match.inspect} for :match, should be one of #{VALID_MATCH.map(&:inspect).join(', ')}" end unhandled_options = @options.keys.reject do |option_name| valid_keys.include?(option_name...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 361, "name": "assert_valid_keys", "signature": "def assert_valid_keys", "start_line": 345 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
apply_expression_filters
capybara/lib/capybara/queries/selector_query.rb
def apply_expression_filters(expression) unapplied_options = options.keys - valid_keys expression_filters.inject(expression) do |expr, (name, ef)| next expr unless apply_filter?(ef) if ef.matcher? unapplied_options.select(&ef.method(:handles_option?)).inject(expr) do |me...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 410, "name": "apply_expression_filters", "signature": "def apply_expression_filters(expression)", "start_line": 391 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
matches_system_filters?
capybara/lib/capybara/queries/selector_query.rb
def matches_system_filters?(node) applied_filters << :system matches_visibility_filters?(node) && matches_id_filter?(node) && matches_class_filter?(node) && matches_style_filter?(node) && matches_focused_filter?(node) && matches_text_filter?(node) && ...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 454, "name": "matches_system_filters?", "signature": "def matches_system_filters?(node)", "start_line": 444 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
matches_spatial_filters?
capybara/lib/capybara/queries/selector_query.rb
def matches_spatial_filters?(node) applied_filters << :spatial return true unless use_spatial_filter? node_rect = Rectangle.new(node.initial_cache[:position] || node.rect) if options[:above] el_rect = rect_cache(options[:above]) return false unless node_rect.above? ...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 490, "name": "matches_spatial_filters?", "signature": "def matches_spatial_filters?(node)", "start_line": 456 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
matches_class_filter?
capybara/lib/capybara/queries/selector_query.rb
def matches_class_filter?(node) return true unless use_default_class_filter? && need_to_process_classes? if options[:class].is_a? Regexp options[:class].match? node[:class] else classes = (node[:class] || '').split options[:class].select { |c| c.is_a? Regexp }.all?...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 509, "name": "matches_class_filter?", "signature": "def matches_class_filter?(node)", "start_line": 498 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
matches_style_filter?
capybara/lib/capybara/queries/selector_query.rb
def matches_style_filter?(node) case options[:style] when String, nil true when Regexp options[:style].match? node[:style] when Hash matches_style?(node, options[:style]) end end
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 535, "name": "matches_style_filter?", "signature": "def matches_style_filter?(node)", "start_line": 526 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
matches_style?
capybara/lib/capybara/queries/selector_query.rb
def matches_style?(node, styles) @actual_styles = node.initial_cache[:style] || node.style(*styles.keys) styles.all? do |style, value| if value.is_a? Regexp value.match? @actual_styles[style.to_s] else @actual_styles[style.to_s] == value end ...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 546, "name": "matches_style?", "signature": "def matches_style?(node, styles)", "start_line": 537 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
matches_visibility_filters?
capybara/lib/capybara/queries/selector_query.rb
def matches_visibility_filters?(node) obscured = options[:obscured] return (visible != :hidden) && (node.initial_cache[:visible] != false) && !node.obscured? if obscured == false vis = case visible when :visible node.initial_cache[:visible] || (node.initial_cache[:visible].nil...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 589, "name": "matches_visibility_filters?", "signature": "def matches_visibility_filters?(node)", "start_line": 566 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
distance
capybara/lib/capybara/queries/selector_query.rb
def distance(other) distance = Float::INFINITY line_segments.each do |ls1| other.line_segments.each do |ls2| distance = [ distance, distance_segment_segment(*ls1, *ls2) ].min end end distance ...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 651, "name": "distance", "signature": "def distance(other)", "start_line": 638 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
distance_segment_segment
capybara/lib/capybara/queries/selector_query.rb
def distance_segment_segment(l1p1, l1p2, l2p1, l2p2) # See http://geomalgorithms.com/a07-_distance.html # rubocop:disable Naming/VariableName u = l1p2 - l1p1 v = l2p2 - l2p1 w = l1p1 - l2p1 a = u.dot u b = u.dot v c = v.dot v d ...
# frozen_string_literal: true require 'matrix' module Capybara module Queries class SelectorQuery < Queries::BaseQuery attr_reader :expression, :selector, :locator, :options SPATIAL_KEYS = %i[above below left_of right_of near].freeze VALID_KEYS = SPATIAL_KEYS + COUNT_KEYS + ...
Ruby
{ "end_line": 755, "name": "distance_segment_segment", "signature": "def distance_segment_segment(l1p1, l1p2, l2p1, l2p2)", "start_line": 686 }
{ "class_name": "SelectorQuery", "class_signature": "class SelectorQuery < < Queries::BaseQuery", "module": "Capybara" }
resolve_for
capybara/lib/capybara/queries/sibling_query.rb
def resolve_for(node, exact = nil) @sibling_node = node node.synchronize do scope = node.respond_to?(:session) ? node.session.current_scope : node.find(:xpath, '/*') match_results = super(scope, exact) siblings = node.find_xpath((XPath.preceding_sibling + XPath.following_si...
# frozen_string_literal: true module Capybara module Queries class SiblingQuery < SelectorQuery # @api private def resolve_for(node, exact = nil) @sibling_node = node node.synchronize do scope = node.respond_to?(:session) ? node.session.current_scope : node.find(:xpath, '/*'...
Ruby
{ "end_line": 17, "name": "resolve_for", "signature": "def resolve_for(node, exact = nil)", "start_line": 7 }
{ "class_name": "SiblingQuery", "class_signature": "class SiblingQuery < < SelectorQuery", "module": "Capybara" }
resolves_for?
capybara/lib/capybara/queries/style_query.rb
def resolves_for?(node) @node = node @actual_styles = node.style(*@expected_styles.keys) @expected_styles.all? do |style, value| if value.is_a? Regexp value.match? @actual_styles[style] else @actual_styles[style] == value end end ...
# frozen_string_literal: true module Capybara # @api private module Queries class StyleQuery < BaseQuery def initialize(expected_styles, session_options:, **options) @expected_styles = stringify_keys(expected_styles) @options = options @actual_styles = {} super(@options) ...
Ruby
{ "end_line": 27, "name": "resolves_for?", "signature": "def resolves_for?(node)", "start_line": 17 }
{ "class_name": "StyleQuery", "class_signature": "class StyleQuery < < BaseQuery", "module": "Capybara" }
initialize
capybara/lib/capybara/queries/text_query.rb
def initialize(type = nil, expected_text, session_options:, **options) # rubocop:disable Style/OptionalArguments @type = type.nil? ? default_type : type raise ArgumentError, "#{@type} is not a valid type for a text query" unless valid_types.include?(@type) @options = options super(@opti...
# frozen_string_literal: true module Capybara # @api private module Queries class TextQuery < BaseQuery def initialize(type = nil, expected_text, session_options:, **options) # rubocop:disable Style/OptionalArguments @type = type.nil? ? default_type : type raise ArgumentError, "#{@type} i...
Ruby
{ "end_line": 25, "name": "initialize", "signature": "def initialize(type = nil, expected_text, session_options:, **options) # rubocop:disable Style/OptionalArguments", "start_line": 7 }
{ "class_name": "TextQuery", "class_signature": "class TextQuery < < BaseQuery", "module": "Capybara" }
build_message
capybara/lib/capybara/queries/text_query.rb
def build_message(report_on_invisible) message = +'' unless (COUNT_KEYS & @options.keys).empty? message << " but found #{@count} #{Capybara::Helpers.declension('time', 'times', @count)}" end message << " in #{@actual_text.inspect}" details_message = [] details_...
# frozen_string_literal: true module Capybara # @api private module Queries class TextQuery < BaseQuery def initialize(type = nil, expected_text, session_options:, **options) # rubocop:disable Style/OptionalArguments @type = type.nil? ? default_type : type raise ArgumentError, "#{@type} i...
Ruby
{ "end_line": 69, "name": "build_message", "signature": "def build_message(report_on_invisible)", "start_line": 55 }
{ "class_name": "TextQuery", "class_signature": "class TextQuery < < BaseQuery", "module": "Capybara" }
submit
capybara/lib/capybara/rack_test/browser.rb
def submit(method, path, attributes, content_type: nil) path = request_path if path.nil? || path.empty? uri = build_uri(path) uri.query = '' if method.to_s.casecmp('get').zero? env = { 'HTTP_REFERER' => referer_url } env['CONTENT_TYPE'] = content_type if content_type process_and_follow_redirects...
# frozen_string_literal: true class Capybara::RackTest::Browser include ::Rack::Test::Methods attr_reader :driver attr_accessor :current_host def initialize(driver) @driver = driver @current_fragment = nil end def app driver.app end def options driver.options end def visit(path...
Ruby
{ "end_line": 46, "name": "submit", "signature": "def submit(method, path, attributes, content_type: nil)", "start_line": 34 }
{ "class_name": "Capybara::RackTest::Browser", "class_signature": "class Capybara::RackTest::Browser", "module": "" }
process_and_follow_redirects
capybara/lib/capybara/rack_test/browser.rb
def process_and_follow_redirects(method, path, attributes = {}, env = {}) @current_fragment = build_uri(path).fragment process(method, path, attributes, env) return unless driver.follow_redirects? driver.redirect_limit.times do if last_response.redirect? if [307, 308].include? last_respon...
# frozen_string_literal: true class Capybara::RackTest::Browser include ::Rack::Test::Methods attr_reader :driver attr_accessor :current_host def initialize(driver) @driver = driver @current_fragment = nil end def app driver.app end def options driver.options end def visit(path...
Ruby
{ "end_line": 72, "name": "process_and_follow_redirects", "signature": "def process_and_follow_redirects(method, path, attributes = {}, env = {})", "start_line": 54 }
{ "class_name": "Capybara::RackTest::Browser", "class_signature": "class Capybara::RackTest::Browser", "module": "" }
build_uri
capybara/lib/capybara/rack_test/browser.rb
def build_uri(path) uri = URI.parse(path) base_uri = base_relative_uri_for(uri) uri.path = base_uri.path + uri.path unless uri.absolute? || uri.path.start_with?('/') if base_uri.absolute? base_uri.merge(uri) else uri.scheme ||= @current_scheme uri.host ||= @current_host uri...
# frozen_string_literal: true class Capybara::RackTest::Browser include ::Rack::Test::Methods attr_reader :driver attr_accessor :current_host def initialize(driver) @driver = driver @current_fragment = nil end def app driver.app end def options driver.options end def visit(path...
Ruby
{ "end_line": 98, "name": "build_uri", "signature": "def build_uri(path)", "start_line": 84 }
{ "class_name": "Capybara::RackTest::Browser", "class_signature": "class Capybara::RackTest::Browser", "module": "" }
base_relative_uri_for
capybara/lib/capybara/rack_test/browser.rb
def base_relative_uri_for(uri) base_uri = URI.parse(base_href) current_uri = URI.parse(safe_last_request&.url.to_s).tap do |c| c.path.sub!(%r{/[^/]*$}, '/') unless uri.path.empty? c.path = '/' if c.path.empty? end if [current_uri, base_uri].any?(&:absolute?) current_uri.merge(base_uri...
# frozen_string_literal: true class Capybara::RackTest::Browser include ::Rack::Test::Methods attr_reader :driver attr_accessor :current_host def initialize(driver) @driver = driver @current_fragment = nil end def app driver.app end def options driver.options end def visit(path...
Ruby
{ "end_line": 170, "name": "base_relative_uri_for", "signature": "def base_relative_uri_for(uri)", "start_line": 157 }
{ "class_name": "Capybara::RackTest::Browser", "class_signature": "class Capybara::RackTest::Browser", "module": "" }
params
capybara/lib/capybara/rack_test/form.rb
def params(button) form_element_types = %i[input select textarea button] form_elements_xpath = XPath.generate do |xp| xpath = xp.descendant(*form_element_types).where(!xp.attr(:form)) xpath += xp.anywhere(*form_element_types).where(xp.attr(:form) == native[:id]) if native[:id] xpath.where(!xp....
# frozen_string_literal: true class Capybara::RackTest::Form < Capybara::RackTest::Node # This only needs to inherit from Rack::Test::UploadedFile because Rack::Test checks for # the class specifically when determining whether to construct the request as multipart. # That check should be based solely on the form...
Ruby
{ "end_line": 52, "name": "params", "signature": "def params(button)", "start_line": 23 }
{ "class_name": "Capybara::RackTest::Form", "class_signature": "class Capybara::RackTest::Form < < Capybara::RackTest::Node", "module": "" }
add_input_param
capybara/lib/capybara/rack_test/form.rb
def add_input_param(field, params) name, value = field['name'].to_s, field['value'].to_s return if name.empty? value = case field['type'] when 'radio', 'checkbox' return unless field['checked'] Capybara::RackTest::Node.new(driver, field).value.to_s when 'file' return if value.emp...
# frozen_string_literal: true class Capybara::RackTest::Form < Capybara::RackTest::Node # This only needs to inherit from Rack::Test::UploadedFile because Rack::Test checks for # the class specifically when determining whether to construct the request as multipart. # That check should be based solely on the form...
Ruby
{ "end_line": 115, "name": "add_input_param", "signature": "def add_input_param(field, params)", "start_line": 93 }
{ "class_name": "Capybara::RackTest::Form", "class_signature": "class Capybara::RackTest::Form < < Capybara::RackTest::Node", "module": "" }
add_select_param
capybara/lib/capybara/rack_test/form.rb
def add_select_param(field, params) name = field['name'] if field.has_attribute?('multiple') value = field.xpath('.//option[@selected]').map do |option| # merge_param!(params, field['name'], (option['value'] || option.text).to_s) (option['value'] || option.text).to_s end params...
# frozen_string_literal: true class Capybara::RackTest::Form < Capybara::RackTest::Node # This only needs to inherit from Rack::Test::UploadedFile because Rack::Test checks for # the class specifically when determining whether to construct the request as multipart. # That check should be based solely on the form...
Ruby
{ "end_line": 139, "name": "add_select_param", "signature": "def add_select_param(field, params)", "start_line": 126 }
{ "class_name": "Capybara::RackTest::Form", "class_signature": "class Capybara::RackTest::Form < < Capybara::RackTest::Node", "module": "" }
set
capybara/lib/capybara/rack_test/node.rb
def set(value, **options) return if disabled? || readonly? warn "Options passed to Node#set but the RackTest driver doesn't support any - ignoring" unless options.empty? if value.is_a?(Array) && !multiple? raise TypeError, "Value cannot be an Array when 'multiple' attribute is not present. Not a #{v...
# frozen_string_literal: true require 'capybara/rack_test/errors' require 'capybara/node/whitespace_normalizer' class Capybara::RackTest::Node < Capybara::Driver::Node include Capybara::Node::WhitespaceNormalizer BLOCK_ELEMENTS = %w[p h1 h2 h3 h4 h5 h6 ol ul pre address blockquote dl div fieldset form hr noscrip...
Ruby
{ "end_line": 46, "name": "set", "signature": "def set(value, **options)", "start_line": 31 }
{ "class_name": "Capybara::RackTest::Node", "class_signature": "class Capybara::RackTest::Node < < Capybara::Driver::Node", "module": "" }
click
capybara/lib/capybara/rack_test/node.rb
def click(keys = [], **options) options.delete(:offset) raise ArgumentError, 'The RackTest driver does not support click options' unless keys.empty? && options.empty? if link? follow_link elsif submits? associated_form = form Capybara::RackTest::Form.new(driver, associated_form).submi...
# frozen_string_literal: true require 'capybara/rack_test/errors' require 'capybara/node/whitespace_normalizer' class Capybara::RackTest::Node < Capybara::Driver::Node include Capybara::Node::WhitespaceNormalizer BLOCK_ELEMENTS = %w[p h1 h2 h3 h4 h5 h6 ol ul pre address blockquote dl div fieldset form hr noscrip...
Ruby
{ "end_line": 77, "name": "click", "signature": "def click(keys = [], **options)", "start_line": 61 }
{ "class_name": "Capybara::RackTest::Node", "class_signature": "class Capybara::RackTest::Node < < Capybara::Driver::Node", "module": "" }
displayed_text
capybara/lib/capybara/rack_test/node.rb
def displayed_text(check_ancestor: true) if !string_node.visible?(check_ancestor) '' elsif native.text? native .text .delete(REMOVED_CHARACTERS) .tr(SQUEEZED_SPACES, ' ') .squeeze(' ') elsif native.element? text = native.children.map do |child| Capyb...
# frozen_string_literal: true require 'capybara/rack_test/errors' require 'capybara/node/whitespace_normalizer' class Capybara::RackTest::Node < Capybara::Driver::Node include Capybara::Node::WhitespaceNormalizer BLOCK_ELEMENTS = %w[p h1 h2 h3 h4 h5 h6 ol ul pre address blockquote dl div fieldset form hr noscrip...
Ruby
{ "end_line": 157, "name": "displayed_text", "signature": "def displayed_text(check_ancestor: true)", "start_line": 139 }
{ "class_name": "Capybara::RackTest::Node", "class_signature": "class Capybara::RackTest::Node < < Capybara::Driver::Node", "module": "" }
set_input
capybara/lib/capybara/rack_test/node.rb
def set_input(value) # rubocop:disable Naming/AccessorMethodName if text_or_password? && attribute_is_not_blank?(:maxlength) # Browser behavior for maxlength="0" is inconsistent, so we stick with # Firefox, allowing no input value = value.to_s[0...self[:maxlength].to_i] end if value.is_a?(...
# frozen_string_literal: true require 'capybara/rack_test/errors' require 'capybara/node/whitespace_normalizer' class Capybara::RackTest::Node < Capybara::Driver::Node include Capybara::Node::WhitespaceNormalizer BLOCK_ELEMENTS = %w[p h1 h2 h3 h4 h5 h6 ol ul pre address blockquote dl div fieldset form hr noscrip...
Ruby
{ "end_line": 236, "name": "set_input", "signature": "def set_input(value) # rubocop:disable Naming/AccessorMethodName", "start_line": 212 }
{ "class_name": "Capybara::RackTest::Node", "class_signature": "class Capybara::RackTest::Node < < Capybara::Driver::Node", "module": "" }
split
capybara/lib/capybara/selector/css.rb
def split(css) selectors = [] StringIO.open(css.to_s) do |str| selector = +'' while (char = str.getc) case char when '[' selector << parse_square(str) when '(' selector << parse_paren(str) ...
# 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
{ "end_line": 57, "name": "split", "signature": "def split(css)", "start_line": 33 }
{ "class_name": "Selector", "class_signature": "class Selector", "module": "Capybara" }
parse_block
capybara/lib/capybara/selector/css.rb
def parse_block(start, final, strio) block = start while (char = strio.getc) case char when final return block + char when '\\' block += char + strio.getc when '"', "'" block += parse_string(char, strio) ...
# 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
{ "end_line": 84, "name": "parse_block", "signature": "def parse_block(start, final, strio)", "start_line": 69 }
{ "class_name": "Selector", "class_signature": "class Selector", "module": "Capybara" }
parse_string
capybara/lib/capybara/selector/css.rb
def parse_string(quote, strio) string = quote while (char = strio.getc) string += char case char when quote return string when '\\' string += strio.getc end end raise ArgumentError, 'Invalid C...
# 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
{ "end_line": 98, "name": "parse_string", "signature": "def parse_string(quote, strio)", "start_line": 86 }
{ "class_name": "Selector", "class_signature": "class Selector", "module": "Capybara" }
initialize
capybara/lib/capybara/selector/definition.rb
def initialize(name, locator_type: nil, raw_locator: false, supports_exact: nil, &block) @name = name @filter_set = Capybara::Selector::FilterSet.add(name) @match = nil @label = nil @failure_message = nil @expressions = {} @expression_filters = {} @locator...
# 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
{ "end_line": 30, "name": "initialize", "signature": "def initialize(name, locator_type: nil, raw_locator: false, supports_exact: nil, &block)", "start_line": 16 }
{ "class_name": "Selector", "class_signature": "class Selector", "module": "Capybara" }
expression
capybara/lib/capybara/selector/definition.rb
def expression(type, allowed_filters, &block) if block @expressions[type] = block allowed_filters = parameter_names(block) if allowed_filters.empty? allowed_filters.flatten.each do |ef| expression_filters[ef] = Capybara::Selector::Filters::IdentityExpressionFilter.new(e...
# 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
{ "end_line": 277, "name": "expression", "signature": "def expression(type, allowed_filters, &block)", "start_line": 268 }
{ "class_name": "Selector", "class_signature": "class Selector", "module": "Capybara" }
describe
capybara/lib/capybara/selector/filter_set.rb
def describe(what = nil, &block) case what when nil undeclared_descriptions.push block when :node_filters node_filter_descriptions.push block when :expression_filters expression_filter_descriptions.push block else raise ArgumentError, 'Unkn...
# 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
{ "end_line": 40, "name": "describe", "signature": "def describe(what = nil, &block)", "start_line": 29 }
{ "class_name": "Selector", "class_signature": "class Selector", "module": "Capybara" }
import
capybara/lib/capybara/selector/filter_set.rb
def import(name, filters = nil) filter_selector = filters.nil? ? ->(*) { true } : ->(filter_name, _) { filters.include? filter_name } self.class[name].tap do |f_set| expression_filters.merge!(f_set.expression_filters.select(&filter_selector)) node_filters.merge!(f_set.node_filters.s...
# 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
{ "end_line": 67, "name": "import", "signature": "def import(name, filters = nil)", "start_line": 56 }
{ "class_name": "Selector", "class_signature": "class Selector", "module": "Capybara" }
combine
capybara/lib/capybara/selector/regexp_disassembler.rb
def combine(strs) suffixes = [[]] strs.reverse_each do |str| if str.is_a? Set prefixes = str.flat_map { |s| combine(s) } suffixes = prefixes.product(suffixes).map { |pair| pair.flatten(1) } else suffixes.each { |arr| arr.unshift str } end...
# 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
{ "end_line": 79, "name": "combine", "signature": "def combine(strs)", "start_line": 68 }
{ "class_name": "Selector", "class_signature": "class Selector", "module": "Capybara" }
extract_strings
capybara/lib/capybara/selector/regexp_disassembler.rb
def extract_strings(process_alternatives) strings = [] each do |exp| next if exp.ignore? next strings.push(nil) if exp.optional? && !process_alternatives next strings.push(exp.alternative_strings) if exp.alternation? && process_alternatives strings....
# 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
{ "end_line": 109, "name": "extract_strings", "signature": "def extract_strings(process_alternatives)", "start_line": 97 }
{ "class_name": "Selector", "class_signature": "class Selector", "module": "Capybara" }
strings
capybara/lib/capybara/selector/regexp_disassembler.rb
def strings(process_alternatives) if indeterminate? [nil] elsif terminal? terminal_strings elsif optional? optional_strings else repeated_strings(process_alternatives) end end
# 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
{ "end_line": 135, "name": "strings", "signature": "def strings(process_alternatives)", "start_line": 125 }
{ "class_name": "Selector", "class_signature": "class Selector", "module": "Capybara" }
call
capybara/lib/capybara/selector/selector.rb
def call(locator, **options) if format raise ArgumentError, "Selector #{@name} does not support #{format}" unless expressions.key?(format) instance_exec(locator, **options, &expressions[format]) else warn 'Selector has no format' end ensure unless locator_valid?(loca...
# 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
{ "end_line": 75, "name": "call", "signature": "def call(locator, **options)", "start_line": 59 }
{ "class_name": "Selector", "class_signature": "class Selector < < SimpleDelegator", "module": "Capybara" }
builder
capybara/lib/capybara/selector/selector.rb
def builder(expr = nil) case format when :css Capybara::Selector::CSSBuilder when :xpath Capybara::Selector::XPathBuilder else raise NotImplementedError, "No builder exists for selector of type #{default_format}" end.new(expr) end
# 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
{ "end_line": 104, "name": "builder", "signature": "def builder(expr = nil)", "start_line": 95 }
{ "class_name": "Selector", "class_signature": "class Selector < < SimpleDelegator", "module": "Capybara" }
locate_field
capybara/lib/capybara/selector/selector.rb
def locate_field(xpath, locator, **_options) return xpath if locator.nil? locate_xpath = xpath # Need to save original xpath for the label wrap locator = locator.to_s attr_matchers = [XPath.attr(:id) == locator, XPath.attr(:name) == locator, XPath.a...
# 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
{ "end_line": 140, "name": "locate_field", "signature": "def locate_field(xpath, locator, **_options)", "start_line": 126 }
{ "class_name": "Selector", "class_signature": "class Selector < < SimpleDelegator", "module": "Capybara" }
load_selenium
capybara/lib/capybara/selenium/driver.rb
def load_selenium require 'selenium-webdriver' require 'capybara/selenium/patches/atoms' require 'capybara/selenium/patches/is_displayed' # Look up the version of `selenium-webdriver` to # see if it's a version we support. # # By default, we use Gem.loaded_specs to determine ...
# 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
{ "end_line": 53, "name": "load_selenium", "signature": "def load_selenium", "start_line": 22 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
browser
capybara/lib/capybara/selenium/driver.rb
def browser unless @browser options[:http_client] ||= begin require 'capybara/selenium/patches/persistent_client' if options[:timeout] ::Capybara::Selenium::PersistentClient.new(read_timeout: options[:timeout]) else ::Capybara::Selenium::PersistentClient.new ...
# 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
{ "end_line": 81, "name": "browser", "signature": "def browser", "start_line": 63 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
initialize
capybara/lib/capybara/selenium/driver.rb
def initialize(app, **options) super() self.class.load_selenium @app = app @browser = nil @exit_status = nil @frame_handles = Hash.new { |hash, handle| hash[handle] = [] } @options = DEFAULT_OPTIONS.merge(options) @node_class = ::Capybara::Selenium::Node end
# 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
{ "end_line": 92, "name": "initialize", "signature": "def initialize(app, **options)", "start_line": 83 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
reset!
capybara/lib/capybara/selenium/driver.rb
def reset! # Use instance variable directly so we avoid starting the browser just to reset the session return unless @browser navigated = false timer = Capybara::Helpers.timer(expire_in: 10) begin # Only trigger a navigation if we haven't done it already, otherwise it # can trigger an e...
# 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
{ "end_line": 176, "name": "reset!", "signature": "def reset!", "start_line": 155 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
frame_obscured_at?
capybara/lib/capybara/selenium/driver.rb
def frame_obscured_at?(x:, y:) frame = @frame_handles[current_window_handle].last return false unless frame switch_to_frame(:parent) begin frame.base.obscured?(x: x, y: y) ensure switch_to_frame(frame) end end
# 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
{ "end_line": 188, "name": "frame_obscured_at?", "signature": "def frame_obscured_at?(x:, y:)", "start_line": 178 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
switch_to_frame
capybara/lib/capybara/selenium/driver.rb
def switch_to_frame(frame) handles = @frame_handles[current_window_handle] case frame when :top handles.clear browser.switch_to.default_content when :parent handles.pop browser.switch_to.parent_frame else handles << frame browser.switch_to.frame(frame.native) ...
# 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
{ "end_line": 203, "name": "switch_to_frame", "signature": "def switch_to_frame(frame)", "start_line": 190 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
open_new_window
capybara/lib/capybara/selenium/driver.rb
def open_new_window(kind = :tab) if browser.switch_to.respond_to?(:new_window) handle = current_window_handle browser.switch_to.new_window(kind) switch_to_window(handle) else browser.manage.new_window(kind) end rescue NoMethodError, Selenium::WebDriver::Error::WebDriverError # ...
# 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
{ "end_line": 258, "name": "open_new_window", "signature": "def open_new_window(kind = :tab)", "start_line": 247 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
quit
capybara/lib/capybara/selenium/driver.rb
def quit @browser&.quit rescue Selenium::WebDriver::Error::SessionNotCreatedError, Errno::ECONNREFUSED, Selenium::WebDriver::Error::InvalidSessionIdError # Browser must have already gone rescue Selenium::WebDriver::Error::UnknownError => e unless silenced_unknown_error_message?(e.message) # Mos...
# 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
{ "end_line": 295, "name": "quit", "signature": "def quit", "start_line": 283 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
invalid_element_errors
capybara/lib/capybara/selenium/driver.rb
def invalid_element_errors @invalid_element_errors ||= [ ::Selenium::WebDriver::Error::StaleElementReferenceError, ::Selenium::WebDriver::Error::ElementNotInteractableError, ::Selenium::WebDriver::Error::InvalidSelectorError, # Work around chromedriver go_back/go_forward race condition...
# 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
{ "end_line": 311, "name": "invalid_element_errors", "signature": "def invalid_element_errors", "start_line": 297 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
clear_session_storage
capybara/lib/capybara/selenium/driver.rb
def clear_session_storage if @browser.respond_to? :session_storage @browser.session_storage.clear else begin @browser&.execute_script('window.sessionStorage.clear()') rescue # rubocop:disable Style/RescueStandardError unless options[:clear_session_storage].nil? warn '...
# 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
{ "end_line": 367, "name": "clear_session_storage", "signature": "def clear_session_storage", "start_line": 355 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
clear_local_storage
capybara/lib/capybara/selenium/driver.rb
def clear_local_storage # selenium-webdriver 4.30.0 removed HTML5 storage accessors -- not really sure why # can we replicate this robustly via CDP? if @browser.respond_to? :local_storage @browser.local_storage.clear else begin @browser&.execute_script('window.localStorage.clear()') ...
# 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
{ "end_line": 383, "name": "clear_local_storage", "signature": "def clear_local_storage", "start_line": 369 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
within_given_window
capybara/lib/capybara/selenium/driver.rb
def within_given_window(handle) original_handle = current_window_handle if handle == original_handle yield else switch_to_window(handle) result = yield switch_to_window(original_handle) result end end
# 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
{ "end_line": 407, "name": "within_given_window", "signature": "def within_given_window(handle)", "start_line": 397 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
find_modal
capybara/lib/capybara/selenium/driver.rb
def find_modal(text: nil, **options) # Selenium has its own built in wait (2 seconds)for a modal to show up, so this wait is really the minimum time # Actual wait time may be longer than specified wait = Selenium::WebDriver::Wait.new( timeout: options.fetch(:wait, session_options.default_max_wait_time...
# 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
{ "end_line": 430, "name": "find_modal", "signature": "def find_modal(text: nil, **options)", "start_line": 409 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }
unwrap_script_result
capybara/lib/capybara/selenium/driver.rb
def unwrap_script_result(arg) case arg when Array arg.map { |arr| unwrap_script_result(arr) } when Hash arg.transform_values! { |value| unwrap_script_result(value) } when Selenium::WebDriver::Element, Selenium::WebDriver::ShadowRoot build_node(arg) else arg end end
# 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
{ "end_line": 455, "name": "unwrap_script_result", "signature": "def unwrap_script_result(arg)", "start_line": 444 }
{ "class_name": "Capybara::Selenium::Driver", "class_signature": "class Capybara::Selenium::Driver < < Capybara::Driver::Base", "module": "" }