xpath 2.0.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +6 -64
- data/lib/xpath/dsl.rb +141 -79
- data/lib/xpath/expression.rb +4 -2
- data/lib/xpath/literal.rb +2 -0
- data/lib/xpath/renderer.rb +34 -82
- data/lib/xpath/union.rb +4 -2
- data/lib/xpath/version.rb +3 -1
- data/lib/xpath.rb +4 -4
- data/spec/fixtures/simple.html +11 -3
- data/spec/spec_helper.rb +7 -0
- data/spec/union_spec.rb +15 -16
- data/spec/xpath_spec.rb +336 -123
- metadata +50 -80
- data/lib/xpath/html.rb +0 -175
- data/spec/html_spec.rb +0 -308
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -1
metadata
CHANGED
@@ -1,159 +1,129 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xpath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
5
|
-
prerelease:
|
4
|
+
version: 3.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jonas Nicklas
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain:
|
12
|
-
-
|
13
|
-
|
14
|
-
Z0lCQVRBTkJna3Foa2lHOXcwQkFRVUZBREJFTVJZd0ZBWURWUVFEREExcWIy
|
15
|
-
NWgKY3k1dWFXTnJiR0Z6TVJVd0V3WUtDWkltaVpQeUxHUUJHUllGWjIxaGFX
|
16
|
-
d3hFekFSQmdvSmtpYUprL0lzWkFFWgpGZ05qYjIwd0hoY05NVE13TXpFMk1E
|
17
|
-
RXpNVEV4V2hjTk1UUXdNekUyTURFek1URXhXakJFTVJZd0ZBWURWUVFECkRB
|
18
|
-
MXFiMjVoY3k1dWFXTnJiR0Z6TVJVd0V3WUtDWkltaVpQeUxHUUJHUllGWjIx
|
19
|
-
aGFXd3hFekFSQmdvSmtpYUoKay9Jc1pBRVpGZ05qYjIwd2dnRWlNQTBHQ1Nx
|
20
|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K09qZTNZVy9wU0FHZ0FWUEdDQ3JscWl3NGhL
|
36
|
-
WlV6UG9iOE5XaHVTNHRLRFBXTUdCUXgzWlNSeXFJTGMKL1dRL0ZtbmJWYTl4
|
37
|
-
UlVvK1JXaVA5VHB6S1FKaVIzQlA5T3BWclJ4MTNtMGV1Rnh6VGk2aWtKekM0
|
38
|
-
NVEzRHE1VgppUXhVbUNDUnNKVmNzU0ZPUkpMZFdOVnF6Qk9XWlJucXJMRHVu
|
39
|
-
em91Q2JjcXppTldrOEtxalpDcjVpdFJpMzE5Ci8ya1pnd2MzMkZIbENkQ0JY
|
40
|
-
a2hFbEVIVC9iR0NGazIrYWpubVdSdHFacHovcG9UZ0VlaGlJVVk9Ci0tLS0t
|
41
|
-
RU5EIENFUlRJRklDQVRFLS0tLS0K
|
42
|
-
date: 2013-04-09 00:00:00.000000000 Z
|
11
|
+
- gem-public_cert.pem
|
12
|
+
date: 2018-10-15 00:00:00.000000000 Z
|
43
13
|
dependencies:
|
44
14
|
- !ruby/object:Gem::Dependency
|
45
15
|
name: nokogiri
|
46
16
|
requirement: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
17
|
requirements:
|
49
|
-
- - ~>
|
18
|
+
- - "~>"
|
50
19
|
- !ruby/object:Gem::Version
|
51
|
-
version: '1.
|
20
|
+
version: '1.8'
|
52
21
|
type: :runtime
|
53
22
|
prerelease: false
|
54
23
|
version_requirements: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
24
|
requirements:
|
57
|
-
- - ~>
|
25
|
+
- - "~>"
|
58
26
|
- !ruby/object:Gem::Version
|
59
|
-
version: '1.
|
27
|
+
version: '1.8'
|
60
28
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
29
|
+
name: pry
|
62
30
|
requirement: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
31
|
requirements:
|
65
|
-
- -
|
32
|
+
- - ">="
|
66
33
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
34
|
+
version: '0'
|
68
35
|
type: :development
|
69
36
|
prerelease: false
|
70
37
|
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
38
|
requirements:
|
73
|
-
- -
|
39
|
+
- - ">="
|
74
40
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
41
|
+
version: '0'
|
76
42
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
43
|
+
name: rake
|
78
44
|
requirement: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
45
|
requirements:
|
81
|
-
- -
|
46
|
+
- - ">="
|
82
47
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0
|
48
|
+
version: '0'
|
84
49
|
type: :development
|
85
50
|
prerelease: false
|
86
51
|
version_requirements: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
52
|
requirements:
|
89
|
-
- -
|
53
|
+
- - ">="
|
90
54
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0
|
55
|
+
version: '0'
|
92
56
|
- !ruby/object:Gem::Dependency
|
93
|
-
name:
|
57
|
+
name: rspec
|
94
58
|
requirement: !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
59
|
requirements:
|
97
|
-
- -
|
60
|
+
- - "~>"
|
98
61
|
- !ruby/object:Gem::Version
|
99
|
-
version: '0'
|
62
|
+
version: '3.0'
|
100
63
|
type: :development
|
101
64
|
prerelease: false
|
102
65
|
version_requirements: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
66
|
requirements:
|
105
|
-
- -
|
67
|
+
- - "~>"
|
106
68
|
- !ruby/object:Gem::Version
|
107
|
-
version: '0'
|
69
|
+
version: '3.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: yard
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.5.8
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.5.8
|
108
84
|
description: XPath is a Ruby DSL for generating XPath expressions
|
109
85
|
email:
|
110
86
|
- jonas.nicklas@gmail.com
|
111
87
|
executables: []
|
112
88
|
extensions: []
|
113
|
-
extra_rdoc_files:
|
114
|
-
- README.md
|
89
|
+
extra_rdoc_files: []
|
115
90
|
files:
|
91
|
+
- README.md
|
92
|
+
- lib/xpath.rb
|
116
93
|
- lib/xpath/dsl.rb
|
117
94
|
- lib/xpath/expression.rb
|
118
|
-
- lib/xpath/html.rb
|
119
95
|
- lib/xpath/literal.rb
|
120
96
|
- lib/xpath/renderer.rb
|
121
97
|
- lib/xpath/union.rb
|
122
98
|
- lib/xpath/version.rb
|
123
|
-
- lib/xpath.rb
|
124
99
|
- spec/fixtures/form.html
|
125
100
|
- spec/fixtures/simple.html
|
126
101
|
- spec/fixtures/stuff.html
|
127
|
-
- spec/html_spec.rb
|
128
102
|
- spec/spec_helper.rb
|
129
103
|
- spec/union_spec.rb
|
130
104
|
- spec/xpath_spec.rb
|
131
|
-
|
132
|
-
|
133
|
-
|
105
|
+
homepage: https://github.com/teamcapybara/xpath
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
134
109
|
post_install_message:
|
135
|
-
rdoc_options:
|
136
|
-
- --main
|
137
|
-
- README.md
|
110
|
+
rdoc_options: []
|
138
111
|
require_paths:
|
139
112
|
- lib
|
140
113
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
-
none: false
|
142
114
|
requirements:
|
143
|
-
- -
|
115
|
+
- - ">="
|
144
116
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
117
|
+
version: '2.3'
|
146
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
-
none: false
|
148
119
|
requirements:
|
149
|
-
- -
|
120
|
+
- - ">="
|
150
121
|
- !ruby/object:Gem::Version
|
151
122
|
version: '0'
|
152
123
|
requirements: []
|
153
|
-
rubyforge_project:
|
154
|
-
rubygems_version:
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.7.7
|
155
126
|
signing_key:
|
156
|
-
specification_version:
|
127
|
+
specification_version: 4
|
157
128
|
summary: Generate XPath expressions from Ruby
|
158
129
|
test_files: []
|
159
|
-
has_rdoc:
|
data/lib/xpath/html.rb
DELETED
@@ -1,175 +0,0 @@
|
|
1
|
-
module XPath
|
2
|
-
module HTML
|
3
|
-
include XPath::DSL::TopLevel
|
4
|
-
extend self
|
5
|
-
|
6
|
-
# Match an `a` link element.
|
7
|
-
#
|
8
|
-
# @param [String] locator
|
9
|
-
# Text, id, title, or image alt attribute of the link
|
10
|
-
#
|
11
|
-
def link(locator)
|
12
|
-
locator = locator.to_s
|
13
|
-
link = descendant(:a)[attr(:href)]
|
14
|
-
link[attr(:id).equals(locator) | string.n.is(locator) | attr(:title).is(locator) | descendant(:img)[attr(:alt).is(locator)]]
|
15
|
-
end
|
16
|
-
|
17
|
-
# Match a `submit`, `image`, or `button` element.
|
18
|
-
#
|
19
|
-
# @param [String] locator
|
20
|
-
# Value, title, id, or image alt attribute of the button
|
21
|
-
#
|
22
|
-
def button(locator)
|
23
|
-
locator = locator.to_s
|
24
|
-
button = descendant(:input)[attr(:type).one_of('submit', 'reset', 'image', 'button')][attr(:id).equals(locator) | attr(:value).is(locator) | attr(:title).is(locator)]
|
25
|
-
button += descendant(:button)[attr(:id).equals(locator) | attr(:value).is(locator) | string.n.is(locator) | attr(:title).is(locator)]
|
26
|
-
button += descendant(:input)[attr(:type).equals('image')][attr(:alt).is(locator)]
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
# Match anything returned by either {#link} or {#button}.
|
31
|
-
#
|
32
|
-
# @param [String] locator
|
33
|
-
# Text, id, title, or image alt attribute of the link or button
|
34
|
-
#
|
35
|
-
def link_or_button(locator)
|
36
|
-
link(locator) + button(locator)
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
# Match any `fieldset` element.
|
41
|
-
#
|
42
|
-
# @param [String] locator
|
43
|
-
# Legend or id of the fieldset
|
44
|
-
#
|
45
|
-
def fieldset(locator)
|
46
|
-
locator = locator.to_s
|
47
|
-
descendant(:fieldset)[attr(:id).equals(locator) | child(:legend)[string.n.is(locator)]]
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
# Match any `input`, `textarea`, or `select` element that doesn't have a
|
52
|
-
# type of `submit`, `image`, or `hidden`.
|
53
|
-
#
|
54
|
-
# @param [String] locator
|
55
|
-
# Label, id, or name of field to match
|
56
|
-
#
|
57
|
-
def field(locator)
|
58
|
-
locator = locator.to_s
|
59
|
-
xpath = descendant(:input, :textarea, :select)[~attr(:type).one_of('submit', 'image', 'hidden')]
|
60
|
-
xpath = locate_field(xpath, locator)
|
61
|
-
xpath
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
# Match any `input` or `textarea` element that can be filled with text.
|
66
|
-
# This excludes any inputs with a type of `submit`, `image`, `radio`,
|
67
|
-
# `checkbox`, `hidden`, or `file`.
|
68
|
-
#
|
69
|
-
# @param [String] locator
|
70
|
-
# Label, id, or name of field to match
|
71
|
-
#
|
72
|
-
def fillable_field(locator)
|
73
|
-
locator = locator.to_s
|
74
|
-
xpath = descendant(:input, :textarea)[~attr(:type).one_of('submit', 'image', 'radio', 'checkbox', 'hidden', 'file')]
|
75
|
-
xpath = locate_field(xpath, locator)
|
76
|
-
xpath
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
# Match any `select` element.
|
81
|
-
#
|
82
|
-
# @param [String] locator
|
83
|
-
# Label, id, or name of the field to match
|
84
|
-
#
|
85
|
-
def select(locator)
|
86
|
-
locator = locator.to_s
|
87
|
-
locate_field(descendant(:select), locator)
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
# Match any `input` element of type `checkbox`.
|
92
|
-
#
|
93
|
-
# @param [String] locator
|
94
|
-
# Label, id, or name of the checkbox to match
|
95
|
-
#
|
96
|
-
def checkbox(locator)
|
97
|
-
locator = locator.to_s
|
98
|
-
locate_field(descendant(:input)[attr(:type).equals('checkbox')], locator)
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
# Match any `input` element of type `radio`.
|
103
|
-
#
|
104
|
-
# @param [String] locator
|
105
|
-
# Label, id, or name of the radio button to match
|
106
|
-
#
|
107
|
-
def radio_button(locator)
|
108
|
-
locator = locator.to_s
|
109
|
-
locate_field(descendant(:input)[attr(:type).equals('radio')], locator)
|
110
|
-
end
|
111
|
-
|
112
|
-
|
113
|
-
# Match any `input` element of type `file`.
|
114
|
-
#
|
115
|
-
# @param [String] locator
|
116
|
-
# Label, id, or name of the file field to match
|
117
|
-
#
|
118
|
-
def file_field(locator)
|
119
|
-
locator = locator.to_s
|
120
|
-
locate_field(descendant(:input)[attr(:type).equals('file')], locator)
|
121
|
-
end
|
122
|
-
|
123
|
-
|
124
|
-
# Match an `optgroup` element.
|
125
|
-
#
|
126
|
-
# @param [String] name
|
127
|
-
# Label for the option group
|
128
|
-
#
|
129
|
-
def optgroup(locator)
|
130
|
-
locator = locator.to_s
|
131
|
-
descendant(:optgroup)[attr(:label).is(locator)]
|
132
|
-
end
|
133
|
-
|
134
|
-
|
135
|
-
# Match an `option` element.
|
136
|
-
#
|
137
|
-
# @param [String] name
|
138
|
-
# Visible text of the option
|
139
|
-
#
|
140
|
-
def option(locator)
|
141
|
-
locator = locator.to_s
|
142
|
-
descendant(:option)[string.n.is(locator)]
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
# Match any `table` element.
|
147
|
-
#
|
148
|
-
# @param [String] locator
|
149
|
-
# Caption or id of the table to match
|
150
|
-
# @option options [Array] :rows
|
151
|
-
# Content of each cell in each row to match
|
152
|
-
#
|
153
|
-
def table(locator)
|
154
|
-
locator = locator.to_s
|
155
|
-
descendant(:table)[attr(:id).equals(locator) | descendant(:caption).is(locator)]
|
156
|
-
end
|
157
|
-
|
158
|
-
# Match any 'dd' element.
|
159
|
-
#
|
160
|
-
# @param [String] locator
|
161
|
-
# Id of the 'dd' element or text from preciding 'dt' element content
|
162
|
-
def definition_description(locator)
|
163
|
-
locator = locator.to_s
|
164
|
-
descendant(:dd)[attr(:id).equals(locator) | previous_sibling(:dt)[string.n.equals(locator)] ]
|
165
|
-
end
|
166
|
-
|
167
|
-
protected
|
168
|
-
|
169
|
-
def locate_field(xpath, locator)
|
170
|
-
locate_field = xpath[attr(:id).equals(locator) | attr(:name).equals(locator) | attr(:placeholder).equals(locator) | attr(:id).equals(anywhere(:label)[string.n.is(locator)].attr(:for))]
|
171
|
-
locate_field += descendant(:label)[string.n.is(locator)].descendant(xpath)
|
172
|
-
locate_field
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|