Module: XPath::HTML
Constant Summary
Constant Summary
Constants included from XPath
Instance Method Summary (collapse)
-
- (Object) button(locator)
Match a `submit`, `image`, or `button` element.
-
- (Object) checkbox(locator)
Match any `input` element of type `checkbox`.
-
- (Object) field(locator)
Match any `input`, `textarea`, or `select` element that doesn't have a type of `submit`, `image`, or `hidden`.
-
- (Object) fieldset(locator)
Match any `fieldset` element.
-
- (Object) file_field(locator)
Match any `input` element of type `file`.
-
- (Object) fillable_field(locator)
Match any `input` or `textarea` element that can be filled with text.
-
- (Object) link(locator)
Match an `a` link element.
- - (Object) link_or_button(locator)
-
- (Object) optgroup(name)
Match an `optgroup` element.
-
- (Object) option(name)
Match an `option` element.
-
- (Object) radio_button(locator)
Match any `input` element of type `radio`.
-
- (Object) select(locator)
Match any `select` element.
-
- (Object) table(locator)
Match any `table` element.
Methods included from XPath
Methods included from DSL::TopLevel
#anywhere, #attr, #axis, #child, #contains, #css, #current, #descendant, #name, #starts_with, #string, #text
Instance Method Details
- (Object) button(locator)
Match a `submit`, `image`, or `button` element.
21 22 23 24 25 |
# File 'lib/xpath/html.rb', line 21 def (locator) = descendant(:input)[attr(:type).one_of('submit', 'reset', 'image', 'button')][attr(:id).equals(locator) | attr(:value).contains(locator) | attr(:title).contains(locator)] += descendant(:button)[attr(:id).equals(locator) | attr(:value).contains(locator) | string.n.contains(locator) | attr(:title).contains(locator)] += descendant(:input)[attr(:type).equals('image')][attr(:alt).contains(locator)] end |
- (Object) checkbox(locator)
Match any `input` element of type `checkbox`.
90 91 92 |
# File 'lib/xpath/html.rb', line 90 def checkbox(locator) locate_field(descendant(:input)[attr(:type).equals('checkbox')], locator) end |
- (Object) field(locator)
Match any `input`, `textarea`, or `select` element that doesn't have a type of `submit`, `image`, or `hidden`.
54 55 56 57 58 |
# File 'lib/xpath/html.rb', line 54 def field(locator) xpath = descendant(:input, :textarea, :select)[~attr(:type).one_of('submit', 'image', 'hidden')] xpath = locate_field(xpath, locator) xpath end |
- (Object) fieldset(locator)
Match any `fieldset` element.
43 44 45 |
# File 'lib/xpath/html.rb', line 43 def fieldset(locator) descendant(:fieldset)[attr(:id).equals(locator) | child(:legend)[string.n.contains(locator)]] end |
- (Object) file_field(locator)
Match any `input` element of type `file`.
110 111 112 |
# File 'lib/xpath/html.rb', line 110 def file_field(locator) locate_field(descendant(:input)[attr(:type).equals('file')], locator) end |
- (Object) fillable_field(locator)
Match any `input` or `textarea` element that can be filled with text. This excludes any inputs with a type of `submit`, `image`, `radio`, `checkbox`, `hidden`, or `file`.
68 69 70 71 72 |
# File 'lib/xpath/html.rb', line 68 def fillable_field(locator) xpath = descendant(:input, :textarea)[~attr(:type).one_of('submit', 'image', 'radio', 'checkbox', 'hidden', 'file')] xpath = locate_field(xpath, locator) xpath end |
- (Object) link(locator)
Match an `a` link element.
11 12 13 14 |
# File 'lib/xpath/html.rb', line 11 def link(locator) link = descendant(:a)[attr(:href)] link[attr(:id).equals(locator) | string.n.contains(locator) | attr(:title).contains(locator) | descendant(:img)[attr(:alt).contains(locator)]] end |
- (Object) link_or_button(locator)
33 34 35 |
# File 'lib/xpath/html.rb', line 33 def (locator) link(locator) + (locator) end |
- (Object) optgroup(name)
Match an `optgroup` element.
120 121 122 |
# File 'lib/xpath/html.rb', line 120 def optgroup(name) descendant(:optgroup)[attr(:label).contains(name)] end |
- (Object) option(name)
Match an `option` element.
130 131 132 |
# File 'lib/xpath/html.rb', line 130 def option(name) descendant(:option)[string.n.equals(name)] end |
- (Object) radio_button(locator)
Match any `input` element of type `radio`.
100 101 102 |
# File 'lib/xpath/html.rb', line 100 def (locator) locate_field(descendant(:input)[attr(:type).equals('radio')], locator) end |
- (Object) select(locator)
Match any `select` element.
80 81 82 |
# File 'lib/xpath/html.rb', line 80 def select(locator) locate_field(descendant(:select), locator) end |
- (Object) table(locator)
Match any `table` element.
142 143 144 |
# File 'lib/xpath/html.rb', line 142 def table(locator) descendant(:table)[attr(:id).equals(locator) | descendant(:caption).contains(locator)] end |