source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/minitest/spec.rb
Ruby
mit
10,156
master
8,035
# 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 ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/driver.rb
Ruby
mit
10,156
master
15,154
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/node.rb
Ruby
mit
10,156
master
17,374
# 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::...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb
Ruby
mit
10,156
master
861
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/driver_specializations/firefox_driver.rb
Ruby
mit
10,156
master
2,555
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/driver_specializations/safari_driver.rb
Ruby
mit
10,156
master
806
# 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 ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/driver_specializations/edge_driver.rb
Ruby
mit
10,156
master
3,760
# 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] =...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/driver_specializations/chrome_driver.rb
Ruby
mit
10,156
master
3,448
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/extensions/scroll.rb
Ruby
mit
10,156
master
2,144
# 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....
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/extensions/file_input_click_emulation.rb
Ruby
mit
10,156
master
791
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/extensions/find.rb
Ruby
mit
10,156
master
4,018
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/extensions/modifier_keys_stack.rb
Ruby
mit
10,156
master
371
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/extensions/html5_drag.rb
Ruby
mit
10,156
master
7,545
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/patches/logs.rb
Ruby
mit
10,156
master
1,367
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/patches/persistent_client.rb
Ruby
mit
10,156
master
358
# 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? ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/patches/atoms.rb
Ruby
mit
10,156
master
428
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/patches/is_displayed.rb
Ruby
mit
10,156
master
303
# 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
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/nodes/firefox_node.rb
Ruby
mit
10,156
master
4,457
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/nodes/safari_node.rb
Ruby
mit
10,156
master
4,093
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/nodes/chrome_node.rb
Ruby
mit
10,156
master
4,315
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/nodes/edge_node.rb
Ruby
mit
10,156
master
3,003
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selenium/nodes/ie_node.rb
Ruby
mit
10,156
master
623
# 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, ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/rack_test/form.rb
Ruby
mit
10,156
master
4,927
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/rack_test/css_handlers.rb
Ruby
mit
10,156
master
282
# frozen_string_literal: true class Capybara::RackTest::CSSHandlers < BasicObject include ::Kernel def disabled(list) list.find_all { |node| node.has_attribute? 'disabled' } end def enabled(list) list.find_all { |node| !node.has_attribute? 'disabled' } end end
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/rack_test/browser.rb
Ruby
mit
10,156
master
4,709
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/rack_test/node.rb
Ruby
mit
10,156
master
8,431
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/rack_test/driver.rb
Ruby
mit
10,156
master
2,060
# frozen_string_literal: true require 'rack/test' require 'rack/utils' require 'mini_mime' require 'nokogiri' class Capybara::RackTest::Driver < Capybara::Driver::Base DEFAULT_OPTIONS = { respect_data_method: false, follow_redirects: true, redirect_limit: 5 }.freeze attr_reader :app, :options def...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/registrations/servers.rb
Ruby
mit
10,156
master
2,849
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/registrations/drivers.rb
Ruby
mit
10,156
master
2,195
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/registrations/patches/puma_ssl.rb
Ruby
mit
10,156
master
654
# 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) ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/session/config.rb
Ruby
mit
10,156
master
4,105
# frozen_string_literal: true require 'delegate' module Capybara class SessionConfig OPTIONS = %i[always_include_port run_server default_selector default_max_wait_time ignore_hidden_elements automatic_reload match exact exact_text raise_server_errors visible_text_only automatic...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/session/matchers.rb
Ruby
mit
10,156
master
3,751
# frozen_string_literal: true module Capybara module SessionMatchers ## # Asserts that the page has the given path. # By default, if passed a full url this will compare against the full url, # if passed a path only the path+query portion will be compared, if passed a regexp # the comparison will ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition.rb
Ruby
mit
10,156
master
11,021
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/filter_set.rb
Ruby
mit
10,156
master
3,997
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/xpath_extensions.rb
Ruby
mit
10,156
master
271
# 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
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/css.rb
Ruby
mit
10,156
master
2,730
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/selector.rb
Ruby
mit
10,156
master
4,489
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/regexp_disassembler.rb
Ruby
mit
10,156
master
5,467
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/filters/base.rb
Ruby
mit
10,156
master
1,866
# frozen_string_literal: true module Capybara class Selector module Filters class Base def initialize(name, matcher, block, **options) @name = name @matcher = matcher @block = block @options = options @options[:valid_values] = [true, false] if optio...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/filters/node_filter.rb
Ruby
mit
10,156
master
782
# frozen_string_literal: true require 'capybara/selector/filters/base' module Capybara class Selector module Filters class NodeFilter < Base def initialize(name, matcher, block, **options) super @block = if boolean? proc do |node, value| error_cnt = er...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/filters/expression_filter.rb
Ruby
mit
10,156
master
559
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/filters/locator_filter.rb
Ruby
mit
10,156
master
722
# frozen_string_literal: true require 'capybara/selector/filters/base' module Capybara class Selector module Filters class LocatorFilter < NodeFilter def initialize(block, **options) super(nil, nil, block, **options) end def matches?(node, value, context = nil, exact:) ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/frame.rb
Ruby
mit
10,156
master
578
# 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_...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/fieldset.rb
Ruby
mit
10,156
master
659
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/link.rb
Ruby
mit
10,156
master
2,096
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/button.rb
Ruby
mit
10,156
master
2,760
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/field.rb
Ruby
mit
10,156
master
1,263
# 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....
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/datalist_input.rb
Ruby
mit
10,156
master
1,161
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/label.rb
Ruby
mit
10,156
master
2,061
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/file_field.rb
Ruby
mit
10,156
master
398
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/checkbox.rb
Ruby
mit
10,156
master
836
# 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) ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/table.rb
Ruby
mit
10,156
master
3,633
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/radio_button.rb
Ruby
mit
10,156
master
860
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/datalist_option.rb
Ruby
mit
10,156
master
796
# 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? ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/element.rb
Ruby
mit
10,156
master
937
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/link_or_button.rb
Ruby
mit
10,156
master
493
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/css.rb
Ruby
mit
10,156
master
367
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/fillable_field.rb
Ruby
mit
10,156
master
1,039
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/select.rb
Ruby
mit
10,156
master
2,790
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/option.rb
Ruby
mit
10,156
master
975
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/table_row.rb
Ruby
mit
10,156
master
873
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/definition/id.rb
Ruby
mit
10,156
master
260
# 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
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/builders/xpath_builder.rb
Ruby
mit
10,156
master
1,993
# frozen_string_literal: true require 'xpath' module Capybara class Selector # @api private class XPathBuilder def initialize(expression) @expression = expression || '' end attr_reader :expression def add_attribute_conditions(**conditions) @expression = conditions.i...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/selector/builders/css_builder.rb
Ruby
mit
10,156
master
2,648
# frozen_string_literal: true require 'xpath' module Capybara class Selector # @api private class CSSBuilder def initialize(expression) @expression = expression || '' end attr_reader :expression def add_attribute_conditions(**attributes) @expression = attributes.inj...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/queries/base_query.rb
Ruby
mit
10,156
master
3,261
# 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) ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/queries/ancestor_query.rb
Ruby
mit
10,156
master
957
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/queries/current_path_query.rb
Ruby
mit
10,156
master
1,644
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/queries/active_element_query.rb
Ruby
mit
10,156
master
384
# frozen_string_literal: true module Capybara # @api private module Queries class ActiveElementQuery < BaseQuery def initialize(**options) @options = options super(@options) end def resolve_for(session) node = session.driver.active_element [Capybara::Node::Ele...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/queries/text_query.rb
Ruby
mit
10,156
master
3,665
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/queries/match_query.rb
Ruby
mit
10,156
master
565
# frozen_string_literal: true module Capybara module Queries class MatchQuery < Capybara::Queries::SelectorQuery def visible options.key?(:visible) ? super : :all end private def assert_valid_keys invalid_options = @options.keys & COUNT_KEYS unless invalid_options....
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/queries/sibling_query.rb
Ruby
mit
10,156
master
977
# 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, '/*'...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/queries/selector_query.rb
Ruby
mit
10,156
master
23,479
# 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 + ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/queries/title_query.rb
Ruby
mit
10,156
master
1,019
# frozen_string_literal: true module Capybara # @api private module Queries class TitleQuery < BaseQuery def initialize(expected_title, **options) @expected_title = expected_title.is_a?(Regexp) ? expected_title : expected_title.to_s @options = options super(@options) @sear...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/queries/style_query.rb
Ruby
mit
10,156
master
1,057
# 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) ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/node/base.rb
Ruby
mit
10,156
master
5,278
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/node/actions.rb
Ruby
mit
10,156
master
19,865
# 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 ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/node/document.rb
Ruby
mit
10,156
master
1,076
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/node/document_matchers.rb
Ruby
mit
10,156
master
2,245
# 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 ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/node/finders.rb
Ruby
mit
10,156
master
17,704
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/node/element.rb
Ruby
mit
10,156
master
20,212
# 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) # ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/node/whitespace_normalizer.rb
Ruby
mit
10,156
master
2,290
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/node/matchers.rb
Ruby
mit
10,156
master
38,212
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/node/simple.rb
Ruby
mit
10,156
master
5,650
# 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...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/test_app.rb
Ruby
mit
10,156
master
6,851
# frozen_string_literal: true require 'sinatra/base' require 'tilt/erb' require 'rack' require 'yaml' class TestApp < Sinatra::Base class TestAppError < Exception; end # rubocop:disable Lint/InheritException class TestAppOtherError < Exception # rubocop:disable Lint/InheritException def initialize(string1, m...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/spec_helper.rb
Ruby
mit
10,156
master
4,447
# frozen_string_literal: true require 'rspec' require 'rspec/expectations' require 'capybara' require 'capybara/rspec' # Required here instead of in rspec_spec to avoid RSpec deprecation warning require 'capybara/spec/test_app' require 'nokogiri' Capybara.save_path = File.join(Dir.pwd, 'save_path_tmp') module Capyba...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/headers_spec.rb
Ruby
mit
10,156
master
279
# frozen_string_literal: true Capybara::SpecHelper.spec '#response_headers' do it 'should return response headers', requires: [:response_headers] do @session.visit('/with_simple_html') expect(@session.response_headers['Content-Type']).to match %r{text/html} end end
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/assert_title_spec.rb
Ruby
mit
10,156
master
2,798
# frozen_string_literal: true Capybara::SpecHelper.spec '#assert_title' do before do @session.visit('/with_js') end it "should not raise if the page's title contains the given string" do expect do @session.assert_title('js') end.not_to raise_error end it 'should not raise when given an em...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/go_forward_spec.rb
Ruby
mit
10,156
master
484
# frozen_string_literal: true Capybara::SpecHelper.spec '#go_forward', requires: [:js] do it 'should fetch a response from the driver from the previous page' do @session.visit('/') expect(@session).to have_content('Hello world!') @session.visit('/foo') expect(@session).to have_content('Another World'...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/all_spec.rb
Ruby
mit
10,156
master
10,461
# frozen_string_literal: true Capybara::SpecHelper.spec '#all' do before do @session.visit('/with_html') end it 'should find all elements using the given locator' do expect(@session.all('//p').size).to eq(3) expect(@session.all('//h1').first.text).to eq('This is a test') expect(@session.all("//i...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/execute_script_spec.rb
Ruby
mit
10,156
master
1,225
# frozen_string_literal: true Capybara::SpecHelper.spec '#execute_script', requires: [:js] do it 'should execute the given script and return nothing' do @session.visit('/with_js') expect(@session.execute_script("document.getElementById('change').textContent = 'Funky Doodle'")).to be_nil expect(@session)....
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/body_spec.rb
Ruby
mit
10,156
master
899
# frozen_string_literal: true Capybara::SpecHelper.spec '#body' do it 'should return the unmodified page body' do @session.visit('/') expect(@session).to have_content('Hello world!') # wait for content to appear if visit is async expect(@session.body).to include('Hello world!') end context 'encoding...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/assert_current_path_spec.rb
Ruby
mit
10,156
master
2,662
# frozen_string_literal: true Capybara::SpecHelper.spec '#assert_current_path' do before do @session.visit('/with_js') end it 'should not raise if the page has the given current path' do expect { @session.assert_current_path('/with_js') }.not_to raise_error end it 'should allow regexp matches' do ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/click_link_or_button_spec.rb
Ruby
mit
10,156
master
4,301
# frozen_string_literal: true Capybara::SpecHelper.spec '#click_link_or_button' do it 'should click on a link' do @session.visit('/with_html') @session.click_link_or_button('labore') expect(@session).to have_content('Bar') end it 'should click on a button' do @session.visit('/form') @session...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/has_css_spec.rb
Ruby
mit
10,156
master
14,416
# frozen_string_literal: true Capybara::SpecHelper.spec '#has_css?' do before do @session.visit('/with_html') end it 'should be true if the given selector is on the page' do expect(@session).to have_css('p') expect(@session).to have_css('p a#foo') end it 'should warn when passed a symbol' do ...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/scroll_spec.rb
Ruby
mit
10,156
master
5,950
# frozen_string_literal: true Capybara::SpecHelper.spec '#scroll_to', requires: [:scroll] do before do @session.visit('/scroll') end it 'can scroll an element to the top of the viewport' do el = @session.find(:css, '#scroll') @session.scroll_to(el, align: :top) expect(el.evaluate_script('this.ge...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/has_ancestor_spec.rb
Ruby
mit
10,156
master
1,324
# frozen_string_literal: true Capybara::SpecHelper.spec '#have_ancestor' do before do @session.visit('/with_html') end it 'should assert an ancestor using the given locator' do el = @session.find(:css, '#ancestor1') expect(el).to have_ancestor(:css, '#ancestor2') end it 'should assert an ancest...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/assert_selector_spec.rb
Ruby
mit
10,156
master
6,221
# frozen_string_literal: true Capybara::SpecHelper.spec '#assert_selector' do before do @session.visit('/with_html') end it 'should be true if the given selector is on the page' do @session.assert_selector(:xpath, '//p') @session.assert_selector(:css, 'p a#foo') @session.assert_selector("//p[con...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/has_selector_spec.rb
Ruby
mit
10,156
master
9,080
# frozen_string_literal: true Capybara::SpecHelper.spec '#has_selector?' do before do @session.visit('/with_html') end it 'should be true if the given selector is on the page' do expect(@session).to have_selector(:xpath, '//p') expect(@session).to have_selector(:css, 'p a#foo') expect(@session)....
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/accept_confirm_spec.rb
Ruby
mit
10,156
master
900
# frozen_string_literal: true Capybara::SpecHelper.spec '#accept_confirm', requires: [:modals] do before do @session.visit('/with_js') end it 'should accept the confirm' do @session.accept_confirm do @session.click_link('Open confirm') end expect(@session).to have_xpath("//a[@id='open-conf...
github
teamcapybara/capybara
https://github.com/teamcapybara/capybara
lib/capybara/spec/session/click_link_spec.rb
Ruby
mit
10,156
master
8,121
# frozen_string_literal: true Capybara::SpecHelper.spec '#click_link' do before do @session.visit('/with_html') end it 'should wait for asynchronous load', requires: [:js] do Capybara.default_max_wait_time = 2 @session.visit('/with_js') @session.click_link('Click me') @session.click_link('Ha...