Class: Capybara::Selector
- Inherits:
-
Object
- Object
- Capybara::Selector
- Defined in:
- lib/capybara/selector.rb
Defined Under Namespace
Classes: Filter
Instance Attribute Summary (collapse)
-
- (Object) custom_filters
readonly
Returns the value of attribute custom_filters.
-
- (Object) format
readonly
Returns the value of attribute format.
-
- (Object) name
readonly
Returns the value of attribute name.
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) call(locator)
-
- (Object) css(&block)
Same as xpath, but wrap in XPath.css().
- - (Object) filter(name, options = {}, &block)
-
- (Selector) initialize(name, &block)
constructor
A new instance of Selector.
- - (Object) label(label = nil)
- - (Object) match(&block)
- - (Boolean) match?(locator)
- - (Object) xpath(&block)
Constructor Details
- (Selector) initialize(name, &block)
A new instance of Selector
39 40 41 42 43 44 45 46 |
# File 'lib/capybara/selector.rb', line 39 def initialize(name, &block) @name = name @custom_filters = {} @match = nil @label = nil @failure_message = nil instance_eval(&block) end |
Instance Attribute Details
- (Object) custom_filters (readonly)
Returns the value of attribute custom_filters
23 24 25 |
# File 'lib/capybara/selector.rb', line 23 def custom_filters @custom_filters end |
- (Object) format (readonly)
Returns the value of attribute format
23 24 25 |
# File 'lib/capybara/selector.rb', line 23 def format @format end |
- (Object) name (readonly)
Returns the value of attribute name
23 24 25 |
# File 'lib/capybara/selector.rb', line 23 def name @name end |
Class Method Details
+ (Object) add(name, &block)
30 31 32 |
# File 'lib/capybara/selector.rb', line 30 def add(name, &block) all[name.to_sym] = Capybara::Selector.new(name.to_sym, &block) end |
+ (Object) all
26 27 28 |
# File 'lib/capybara/selector.rb', line 26 def all @selectors ||= {} end |
+ (Object) remove(name)
34 35 36 |
# File 'lib/capybara/selector.rb', line 34 def remove(name) all.delete(name.to_sym) end |
Instance Method Details
- (Object) call(locator)
71 72 73 74 75 76 77 |
# File 'lib/capybara/selector.rb', line 71 def call(locator) if @format==:css @css.call(locator) else @xpath.call(locator) end end |
- (Object) css(&block)
Same as xpath, but wrap in XPath.css().
55 56 57 58 59 |
# File 'lib/capybara/selector.rb', line 55 def css(&block) @format = :css @css = block if block @css end |
- (Object) filter(name, options = {}, &block)
83 84 85 |
# File 'lib/capybara/selector.rb', line 83 def filter(name, ={}, &block) @custom_filters[name] = Filter.new(name, block, ) end |
- (Object) label(label = nil)
66 67 68 69 |
# File 'lib/capybara/selector.rb', line 66 def label(label=nil) @label = label if label @label end |
- (Object) match(&block)
61 62 63 64 |
# File 'lib/capybara/selector.rb', line 61 def match(&block) @match = block if block @match end |
- (Boolean) match?(locator)
79 80 81 |
# File 'lib/capybara/selector.rb', line 79 def match?(locator) @match and @match.call(locator) end |
- (Object) xpath(&block)
48 49 50 51 52 |
# File 'lib/capybara/selector.rb', line 48 def xpath(&block) @format = :xpath @xpath = block if block @xpath end |