watir-formhandler 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b92e73452df613d4cebbab78ba085259a504b00e
4
- data.tar.gz: 078a6861a8b11e88e9c1675c3b7c877d1991b062
3
+ metadata.gz: 56ab0c2b068798ca27c07cb6f83f617d9ccb8315
4
+ data.tar.gz: 32008f45d343055e6e9f30210d14d6feaffee9d1
5
5
  SHA512:
6
- metadata.gz: 12d2941e5e8b6f3de215eaa2e5bc8088e6629c7f8dc3c6b452d83aeb1475b4ae94c614b50942f085ba973c10e40491aea575b53262708b759d9956692802b3c5
7
- data.tar.gz: 0231e8ffe1c62f472da7626c69ce5821b0a552c1dcd19d7b9353d7a9e2435d1b5b8e194bdeaab8cb5ad8ab2d2367ea45181f273c0c63586ce61b52fc8ac3d2ba
6
+ metadata.gz: a0df8ee522f0540a9b4190b3a99d87ebb5fef276cb5262de23aae70f586d67a2246ca5a9007da2701297e30031d2d5ad7a1725a73181049261cbcda5e345ac09
7
+ data.tar.gz: f8b78f130d760a25dd3c47e4a9de326d74c78d83bc8c6f3c73346a0843d508ab2c291a76cc1176ef026c73822eeeed096db9f98f147f1657dcec38e5674ecdd1
@@ -0,0 +1,6 @@
1
+ [![Code Climate](https://codeclimate.com/github/Dervol03/watir-formhandler/badges/gpa.svg)](https://codeclimate.com/github/Dervol03/watir-formhandler)
2
+
3
+ watir-formhandler
4
+ =================
5
+
6
+ Provides comfort methods for watir to fill in forms
@@ -1,5 +1,7 @@
1
+ require 'watir-webdriver/elements/checkbox'
1
2
  module Watir
2
- require 'watir-webdriver/elements/checkbox'
3
+
4
+ # Extends the Watir::Checkbox class with set and field_value methods.
3
5
  class CheckBox
4
6
 
5
7
  # Will click the CheckBox unless the #checked? returns the same value as the given one.
@@ -5,11 +5,19 @@ module Watir
5
5
  # @param [String, Watir::Label] label the label for which to find the form field.
6
6
  # @param [Watir::Element] start_node the node where to start searching for the label.
7
7
  # @param [Boolean] include_groups whether to detect the group of a given label.
8
+ # @param [Boolean] placeholder whether to handle label as Watir::Label or as placeholder
9
+ # attribute for an input field.
10
+ #
8
11
  # @return [Watir::Element] form field of the given label.
9
- def field(label, start_node: nil, include_groups: false)
12
+ def field(label, start_node: nil, include_groups: false, placeholder: false)
10
13
  start_node ||= self
11
- field_label = label.respond_to?(:for) ? label : start_node.label(text: label)
12
- determine_field(start_node, field_label, include_groups)
14
+
15
+ if placeholder
16
+ start_node.element(placeholder: label).to_subtype
17
+ else
18
+ field_label = label.respond_to?(:for) ? label : start_node.label(text: label)
19
+ determine_field(start_node, field_label, include_groups)
20
+ end
13
21
  end
14
22
 
15
23
 
@@ -19,8 +27,14 @@ module Watir
19
27
  # @param [Watir::Element] start_node the node where to start searching for the label.
20
28
  # @param [String, Boolean, Array] value to be set.
21
29
  # @param [Boolean] include_groups whether to detect the group of a given label.
22
- def fill_in(label, value, start_node: nil, include_groups: nil)
23
- field(label, start_node: start_node, include_groups: include_groups).set(value)
30
+ # @param [Boolean] placeholder whether to handle label as Watir::Label or as placeholder
31
+ # attribute for an input field.
32
+ def fill_in(label, value, start_node: nil, include_groups: nil, placeholder: false)
33
+ field(label,
34
+ start_node: start_node,
35
+ include_groups: include_groups,
36
+ placeholder: placeholder
37
+ ).set(value)
24
38
  end
25
39
 
26
40
 
@@ -41,8 +55,7 @@ module Watir
41
55
  return option_group(label.parent) if group_member_count > 1
42
56
  end
43
57
 
44
- field_id = label.for
45
- found_field = start_node.element(id: field_id)
58
+ found_field = start_node.element(id: label.for)
46
59
  found_field ? found_field.to_subtype : nil
47
60
  end
48
61
  end
@@ -1,4 +1,6 @@
1
1
  module Watir
2
+
3
+ # Extends the Watir::Element class to get public access on the :selector.
2
4
  class Element
3
5
  attr_reader :selector
4
6
  end
@@ -1,4 +1,6 @@
1
1
  module Watir
2
+
3
+ # Extends the Watir::FileField class for #field_value.
2
4
  class FileField
3
5
  # Returns the file name of this FileField as a string.
4
6
  # @return [String] file name.
@@ -1,5 +1,7 @@
1
+ require 'watir-webdriver/elements/radio'
1
2
  module Watir
2
- require 'watir-webdriver/elements/radio'
3
+
4
+ # Extends the Watir::Radio class to add #set and #field_value methods.
3
5
  class Radio
4
6
  # Clicks this Radio unless #checked? returns the same value as the given one.
5
7
  # @param [Boolean] value to be set.
@@ -1,5 +1,8 @@
1
+ require 'watir-webdriver/elements/select'
1
2
  module Watir
2
- require 'watir-webdriver/elements/select'
3
+
4
+ # Extends the Watir::Select class for the #set and #field_value methods and also adds the means
5
+ # to select multiple options when possible.
3
6
  class Select
4
7
  # Selects the given option(s) of this Select. If this Select has the 'multiple' attribute, it
5
8
  # accept an array, otherwise it will call the internal '#select' method.
@@ -1,4 +1,6 @@
1
1
  module Watir
2
+
3
+ # Extends the Watir::TextArea class to add #field_value.
2
4
  class TextArea
3
5
  # Returns the text currently set in this TextField
4
6
  # @return [String] the current text in the field. If the field is not set at all, it will return
@@ -1,4 +1,6 @@
1
1
  module Watir
2
+
3
+ # Extends the Watir::TextField to add #field_value.
2
4
  class TextField
3
5
  # Returns the text currently set in this TextField
4
6
  # @return [String] the current text in the field. If the field is not set at all, it will return
@@ -10,4 +10,13 @@ module Watir
10
10
  @tag_to_class = @tag_to_class.dup.merge(tag => tag_class)
11
11
  @tag_to_class.freeze
12
12
  end
13
+
14
+
15
+ # Adds the placeholder attribute to input fields to allow them to be searched by it. I tried to
16
+ # call the attribute method on Input and even TextField at first, but HTMLElement was the only one
17
+ # with which it was successfully added. This should surely be fixed some day.
18
+ class HTMLElement
19
+ # TODO: find a way to move this call into TextField and TextArea where it belongs.
20
+ attribute('String', :placeholder, :placeholder)
21
+ end
13
22
  end
@@ -118,6 +118,17 @@ module Watir
118
118
  end
119
119
  end
120
120
  end # describe sybtype
121
+
122
+
123
+ describe 'using placeholder: true' do
124
+ it 'returns Watir::TextField for a text field with a placeholder' do
125
+ expect(browser.field('Placeholder Text', placeholder: true)).to be_an Watir::TextField
126
+ end
127
+
128
+ it 'returns Watir::TextArea for a text area with a placeholder' do
129
+ expect(browser.field('Placeholder Area', placeholder: true)).to be_an Watir::TextArea
130
+ end
131
+ end
121
132
  end # #field
122
133
 
123
134
 
@@ -236,6 +247,21 @@ module Watir
236
247
  expect(option_group.selected_options).to eq(%w(Checkbox5 Radio7))
237
248
  end
238
249
  end # descibe: with a start node
250
+
251
+
252
+ describe 'with placeholder: true' do
253
+ it 'fills a Watir::TextField with given text' do
254
+ target_field = browser.text_field(id: 'placeholder_text')
255
+ browser.fill_in('Placeholder Text', 'Test Text', placeholder: true)
256
+ expect(target_field.value).to eq('Test Text')
257
+ end
258
+
259
+ it 'fills a Watir::TextArea with given text' do
260
+ target_field = browser.textarea(id: 'placeholder_area')
261
+ browser.fill_in('Placeholder Area', 'Test Text', placeholder: true)
262
+ expect(target_field.value).to eq('Test Text')
263
+ end
264
+ end# with placeholder: true
239
265
  end # #fill_in
240
266
  end
241
267
 
@@ -1,4 +1,4 @@
1
- <html>
1
+ <html xmlns="http://www.w3.org/1999/html">
2
2
  <head>
3
3
  <title>Example Form</title>
4
4
  </head>
@@ -39,7 +39,15 @@
39
39
  <br />
40
40
 
41
41
  <label for="file">File</label>
42
- <input type="file" id="file">
42
+ <input type="file" id="file" />
43
+ <br />
44
+ <br />
45
+
46
+ <input type="text" id="placeholder_text" placeholder="Placeholder Text" />
47
+ <br />
48
+ <br />
49
+
50
+ <textarea id="placeholder_area" placeholder="Placeholder Area"></textarea>
43
51
  <br />
44
52
  <br />
45
53
 
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.1.0
4
+ version: 2.3.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-09-14 00:00:00.000000000 Z
11
+ date: 2014-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: watir
@@ -30,35 +30,23 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.10
33
+ version: 0.6.11
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.6.10
41
- - !ruby/object:Gem::Dependency
42
- name: selenium-webdriver
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 2.42.0
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 2.42.0
40
+ version: 0.6.11
55
41
  description: Adds some convenience methods to fill out forms in Watir
56
42
  email:
57
43
  - b_d_v@web.de
58
44
  executables: []
59
45
  extensions: []
60
- extra_rdoc_files: []
46
+ extra_rdoc_files:
47
+ - README.md
61
48
  files:
49
+ - README.md
62
50
  - lib/watir_formhandler.rb
63
51
  - lib/watir_formhandler/check_box.rb
64
52
  - lib/watir_formhandler/container.rb
@@ -81,7 +69,7 @@ files:
81
69
  - spec/text_area_spec.rb
82
70
  - spec/text_field_spec.rb
83
71
  - spec/watir_spec.rb
84
- homepage: http://rubygems.org/gems/watir-formhandler
72
+ homepage: http://github.com/Dervol03/watir-formhandler
85
73
  licenses:
86
74
  - MIT
87
75
  metadata: {}
@@ -91,12 +79,12 @@ require_paths:
91
79
  - lib
92
80
  required_ruby_version: !ruby/object:Gem::Requirement
93
81
  requirements:
94
- - - ">="
82
+ - - '>='
95
83
  - !ruby/object:Gem::Version
96
84
  version: '0'
97
85
  required_rubygems_version: !ruby/object:Gem::Requirement
98
86
  requirements:
99
- - - ">="
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  requirements: []