watir-formhandler 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/watir-formhandler/container.rb +8 -3
- data/spec/container_spec.rb +21 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7872b31d757af03a3e28a3bc3f57fd37faba24c5
|
4
|
+
data.tar.gz: 41a89b39e932f12d1394628c88721d0cb4ffae7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd4e003626c969d6dbeea15c4981270f0ac181ba1545f6fc8ab8d11e3a7ae69012c3bcdb84970cc8394efcdb625c753c7d59c30fc11e267c5559748ee36dd89c
|
7
|
+
data.tar.gz: 164b621310c0d3f79e3e83dcbc509c5d10758aec47821e38552ded8f2f24061b07820818272e8d8b9370e168c547cd330ba9a098159e12f36475f0aafbb4f8cd
|
@@ -7,13 +7,16 @@ module Watir
|
|
7
7
|
# @param [Boolean] include_groups whether to detect the group of a given label.
|
8
8
|
# @param [Boolean] placeholder whether to handle label as Watir::Label or as placeholder
|
9
9
|
# attribute for an input field.
|
10
|
+
# @param [Boolean] id assumes the given label is an HTML ID and searches for it.
|
10
11
|
#
|
11
12
|
# @return [Watir::Element] form field of the given label.
|
12
|
-
def field(label, start_node: nil, include_groups: false, placeholder: false)
|
13
|
+
def field(label, start_node: nil, include_groups: false, placeholder: false, id: false)
|
13
14
|
start_node ||= self
|
14
15
|
|
15
16
|
if placeholder
|
16
17
|
start_node.element(placeholder: label).to_subtype
|
18
|
+
elsif id
|
19
|
+
start_node.element(id: label).to_subtype
|
17
20
|
else
|
18
21
|
field_label = label.respond_to?(:for) ? label : start_node.label(text: label)
|
19
22
|
determine_field(start_node, field_label, include_groups)
|
@@ -29,11 +32,13 @@ module Watir
|
|
29
32
|
# @param [Boolean] include_groups whether to detect the group of a given label.
|
30
33
|
# @param [Boolean] placeholder whether to handle label as Watir::Label or as placeholder
|
31
34
|
# attribute for an input field.
|
32
|
-
|
35
|
+
# @param [Boolean] id assumes the given label is an HTML ID and searches for it.
|
36
|
+
def fill_in(label, value, start_node: nil, include_groups: nil, placeholder: false, id: false)
|
33
37
|
field(label,
|
34
38
|
start_node: start_node,
|
35
39
|
include_groups: include_groups,
|
36
|
-
placeholder: placeholder
|
40
|
+
placeholder: placeholder,
|
41
|
+
id: id
|
37
42
|
).set(value)
|
38
43
|
end
|
39
44
|
|
data/spec/container_spec.rb
CHANGED
@@ -38,7 +38,7 @@ module Watir
|
|
38
38
|
field_label = browser.label(text: 'Checkbox')
|
39
39
|
expect(browser.field(field_label).id).to eq('checkbox')
|
40
40
|
end
|
41
|
-
end
|
41
|
+
end# without start_node
|
42
42
|
|
43
43
|
|
44
44
|
describe 'with a start node' do
|
@@ -56,7 +56,7 @@ module Watir
|
|
56
56
|
start_node = browser.element(id: 'main_content')
|
57
57
|
expect(browser.field('Checkbox', start_node: start_node).id).to eq('checkbox')
|
58
58
|
end
|
59
|
-
end
|
59
|
+
end# with start_node
|
60
60
|
|
61
61
|
|
62
62
|
context 'specifying the label with a Watir::Label' do
|
@@ -74,7 +74,7 @@ module Watir
|
|
74
74
|
expect(browser.field(field_label, start_node: start_node).id).to eq('checkbox')
|
75
75
|
end
|
76
76
|
end
|
77
|
-
end
|
77
|
+
end# Watir::Label
|
78
78
|
|
79
79
|
|
80
80
|
describe 'depending on subtype' do
|
@@ -129,6 +129,15 @@ module Watir
|
|
129
129
|
expect(browser.field('Placeholder Area', placeholder: true)).to be_an Watir::TextArea
|
130
130
|
end
|
131
131
|
end
|
132
|
+
|
133
|
+
|
134
|
+
describe 'using id: true' do
|
135
|
+
it 'returns field with id given as label' do
|
136
|
+
text_id = 'text'
|
137
|
+
expect(browser.field(text_id, id: true)).to be_an Watir::TextField
|
138
|
+
expect(browser.field(text_id, id: true).id).to eq(text_id)
|
139
|
+
end
|
140
|
+
end
|
132
141
|
end # #field
|
133
142
|
|
134
143
|
|
@@ -262,6 +271,15 @@ module Watir
|
|
262
271
|
expect(target_field.value).to eq('Test Text')
|
263
272
|
end
|
264
273
|
end# with placeholder: true
|
274
|
+
|
275
|
+
|
276
|
+
describe 'using id: true', wip: true do
|
277
|
+
it 'fills field with specified id' do
|
278
|
+
text_id = 'text'
|
279
|
+
browser.fill_in(text_id, 'test', id: true)
|
280
|
+
expect(browser.field(text_id, id: true).value).to eq('test')
|
281
|
+
end
|
282
|
+
end# using id: true
|
265
283
|
end # #fill_in
|
266
284
|
end
|
267
285
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir-formhandler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yves Komenda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: watir
|