Module: Capybarista::Queries::XPath
- Defined in:
- lib/capybarista/queries.rb
Class Method Summary collapse
-
.all_fields ⇒ Object
Queries returns all fields that accept user input.
- .labels_for(*ids) ⇒ Object
- .string(value) ⇒ Object
Class Method Details
.all_fields ⇒ Object
Queries returns all fields that accept user input
26 27 28 |
# File 'lib/capybarista/queries.rb', line 26 def self.all_fields ".//*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden' or ./@type='button')]" end |
.labels_for(*ids) ⇒ Object
30 31 32 33 |
# File 'lib/capybarista/queries.rb', line 30 def self.labels_for(*ids) condition = ids.map{|id| "@for=#{string(id)}" }.join(" or ") "//label[#{condition}]" end |
.string(value) ⇒ Object
13 14 15 16 17 |
# File 'lib/capybarista/queries.rb', line 13 def self.string(value) # The underlying API changes betw/ versions # 0.1.4 and 2.0.0 . So, let's wrap the method. ::XPath::Expression::StringLiteral.new(value.to_s).to_xpath end |