watir 6.10.2 → 6.10.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 35437148dba077a0fd8b69718c3a752b7a82bdce
4
- data.tar.gz: 4c7e9a65b26dbb86c5c1b0540941bee585b74fe6
2
+ SHA256:
3
+ metadata.gz: 35bf21c910e97a772d03a1ec9711edebd7bfd9231bc2beb911542fd302a4b6ef
4
+ data.tar.gz: bc8595b914786c02087e0b7689885e1b0ed0c7e77487ff0b4796a00d5f381b69
5
5
  SHA512:
6
- metadata.gz: f3f3441a9c7d1f3493317cc214c155d486f9816d3dab30371c638b0e355a142e012f9412889065d957010f62483684f3182b30b9c1abc83606719e9bad47f379
7
- data.tar.gz: a216c1ced631cb446e7ce4f813340a0dc91e80c2efb39a0179095c276c79d42ec0a5eec4dba6d1310dc51c7c380a89318176fd1425d7eed5113b4368ddb1f772
6
+ metadata.gz: 119768b890d1fc7daaff5b690619abbf66ac32e35b35fcde533df812d156815c8b8d4dbc742875ebb164f0002d44962c1b6b803c9914f1b9794af469ce5ac034
7
+ data.tar.gz: 352c1f1f616e64cdac24e1b98d771a96be911a932b3e5c9f490f1d8dcac6644b623a72705b4c4f81cbfcd0c4f3a1a296a734674d2a1c3733c2417b6fe07987a9
@@ -7,6 +7,9 @@ cache: bundler
7
7
  notifications:
8
8
  slack:
9
9
  secure: BLsBCm33R32VNRccrLx9F0P24X6BVpVHj1OWaN4Kyn6g9qXteIwC2VKVMnKNbifpojfMkrn0OeFQFK1O1DSOsC3mgzn/udoB+DnUGcSemFUn04xhbYF5SI+3zGPKPo0JLvjjdEKSSma84YwKdrj88pGUK34p01gL8hiaqjFzWdk=
10
+ before_install:
11
+ - gem update --system
12
+
10
13
  before_script:
11
14
  - support/travis.sh
12
15
  - export PATH=~/.webdrivers:$PATH
@@ -16,13 +19,16 @@ script: bundle exec rake $RAKE_TASK
16
19
  _version:
17
20
  two: &two
18
21
  language: ruby
19
- rvm: 2.2.7
22
+ rvm: 2.2.9
20
23
  three: &three
21
24
  language: ruby
22
- rvm: 2.3.4
25
+ rvm: 2.3.6
23
26
  four: &four
24
27
  language: ruby
25
- rvm: 2.4.1
28
+ rvm: 2.4.3
29
+ five: &five
30
+ language: ruby
31
+ rvm: 2.5.0
26
32
 
27
33
  _browsers:
28
34
  firefox: &firefox-latest
@@ -58,6 +64,9 @@ matrix:
58
64
  - env: RAKE_TASK=spec:chrome
59
65
  <<: *three
60
66
  <<: *chrome
67
+ - env: RAKE_TASK=spec:chrome
68
+ <<: *five
69
+ <<: *chrome
61
70
  - env: RAKE_TASK=spec:chrome
62
71
  <<: *two
63
72
  <<: *chrome
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 6.10.3 (2018-01-26)
2
+
3
+ * Add special handling for `date_field` and `date_time_field` input types
4
+
1
5
  ### 6.10.2 (2017-12-13)
2
6
 
3
7
  * Fix bug in `#exists?` for elements nested in IFrames
data/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
  (the MIT License)
2
2
 
3
3
  Copyright (c) 2009-2015 Jari Bakken
4
- Copyright (c) 2015-2017 Alex Rodionov, Titus Fortner
4
+ Copyright (c) 2015-2018 Alex Rodionov, Titus Fortner
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining
7
7
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -102,5 +102,5 @@ rake yard:doctest
102
102
  ## Copyright
103
103
 
104
104
  Copyright (c) 2009-2015 Jari Bakken
105
- Copyright (c) 2015-2017 Alex Rodionov, Titus Fortner
105
+ Copyright (c) 2015-2018 Alex Rodionov, Titus Fortner
106
106
  See LICENSE for details
@@ -131,6 +131,8 @@ require 'watir/elements/area'
131
131
  require 'watir/elements/button'
132
132
  require 'watir/elements/cell'
133
133
  require 'watir/elements/checkbox'
134
+ require 'watir/elements/date_field'
135
+ require 'watir/elements/date_time_field'
134
136
  require 'watir/elements/dlist'
135
137
  require 'watir/elements/file_field'
136
138
  require 'watir/elements/font'
@@ -0,0 +1,41 @@
1
+ module Watir
2
+ class DateField < Input
3
+
4
+ #
5
+ # Enter the provided value.
6
+ #
7
+
8
+ def set!(date)
9
+ date = Date.parse date if date.is_a?(String)
10
+
11
+ message = "DateField##{__callee__} only accepts instances of Date or Time"
12
+ raise ArgumentError, message unless [Date, ::Time].include?(date.class)
13
+
14
+ date_string = date.strftime("%Y-%m-%d")
15
+ element_call(:wait_for_writable) { execute_js(:setValue, @element, date_string) }
16
+ end
17
+ alias_method :set, :set!
18
+ alias_method :value=, :set
19
+
20
+ protected
21
+
22
+ end # DateField
23
+
24
+ module Container
25
+ def date_field(*args)
26
+ DateField.new(self, extract_selector(args).merge(tag_name: "input", type: "date"))
27
+ end
28
+
29
+ def date_fields(*args)
30
+ DateFieldCollection.new(self, extract_selector(args).merge(tag_name: "input", type: "date"))
31
+ end
32
+ end # Container
33
+
34
+ class DateFieldCollection < InputCollection
35
+ private
36
+
37
+ def element_class
38
+ DateField
39
+ end
40
+ end # DateFieldCollection
41
+ end # Watir
@@ -0,0 +1,41 @@
1
+ module Watir
2
+ class DateTimeField < Input
3
+
4
+ #
5
+ # Enter the provided value.
6
+ #
7
+
8
+ def set!(date)
9
+ date = DateTime.parse date if date.is_a?(String)
10
+
11
+ message = "DateTimeField##{__callee__} only accepts instances of DateTime or Time"
12
+ raise ArgumentError, message unless [DateTime, ::Time].include?(date.class)
13
+
14
+ date_time_string = date.strftime("%Y-%m-%dT%H:%M")
15
+ element_call(:wait_for_writable) { execute_js(:setValue, @element, date_time_string) }
16
+ end
17
+ alias_method :set, :set!
18
+ alias_method :value=, :set
19
+
20
+ protected
21
+
22
+ end # DateTimeField
23
+
24
+ module Container
25
+ def date_time_field(*args)
26
+ DateTimeField.new(self, extract_selector(args).merge(tag_name: "input", type: "datetime-local"))
27
+ end
28
+
29
+ def date_time_fields(*args)
30
+ DateTimeFieldCollection.new(self, extract_selector(args).merge(tag_name: "input", type: "datetime-local"))
31
+ end
32
+ end # Container
33
+
34
+ class DateTimeFieldCollection < InputCollection
35
+ private
36
+
37
+ def element_class
38
+ DateTimeField
39
+ end
40
+ end # DateTimeFieldCollection
41
+ end # Watir
@@ -2,7 +2,7 @@ module Watir
2
2
  class TextField < Input
3
3
  include UserEditable
4
4
 
5
- NON_TEXT_TYPES = %w[file radio checkbox submit reset image button hidden range color]
5
+ NON_TEXT_TYPES = %w[file radio checkbox submit reset image button hidden range color date datetime-local]
6
6
 
7
7
  protected
8
8
 
@@ -2,7 +2,7 @@ module Watir
2
2
  module UserEditable
3
3
 
4
4
  #
5
- # Clear the element, the type in the given value.
5
+ # Clear the element, then type in the given value.
6
6
  #
7
7
  # @param [String, Symbol] args
8
8
  #
@@ -0,0 +1,183 @@
1
+ require "watirspec_helper"
2
+
3
+ describe "DateField" do
4
+
5
+ before :each do
6
+ browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
7
+ end
8
+
9
+ # Exists method
10
+ describe "#exists?" do
11
+ it "returns true if the element exists" do
12
+ expect(browser.date_field(id: 'html5_date')).to exist
13
+ expect(browser.date_field(id: /html5_date/)).to exist
14
+ expect(browser.date_field(name: 'html5_date')).to exist
15
+ expect(browser.date_field(name: /html5_date/)).to exist
16
+ expect(browser.date_field(text: '')).to exist
17
+ expect(browser.date_field(text: //)).to exist
18
+ expect(browser.date_field(index: 0)).to exist
19
+ expect(browser.date_field(xpath: "//input[@id='html5_date']")).to exist
20
+ expect(browser.date_field(label: "HTML5 Date")).to exist
21
+ expect(browser.date_field(label: /Date$/)).to exist
22
+ end
23
+
24
+ it "returns the date field if given no args" do
25
+ expect(browser.date_field).to exist
26
+ end
27
+
28
+ it "respects date fields types" do
29
+ expect(browser.date_field.type).to eq('date')
30
+ end
31
+
32
+ it "returns false if the element does not exist" do
33
+ expect(browser.date_field(id: 'no_such_id')).to_not exist
34
+ expect(browser.date_field(id: /no_such_id/)).to_not exist
35
+ expect(browser.date_field(name: 'no_such_name')).to_not exist
36
+ expect(browser.date_field(name: /no_such_name/)).to_not exist
37
+ expect(browser.date_field(value: 'no_such_value')).to_not exist
38
+ expect(browser.date_field(value: /no_such_value/)).to_not exist
39
+ expect(browser.date_field(text: 'no_such_text')).to_not exist
40
+ expect(browser.date_field(text: /no_such_text/)).to_not exist
41
+ expect(browser.date_field(class: 'no_such_class')).to_not exist
42
+ expect(browser.date_field(class: /no_such_class/)).to_not exist
43
+ expect(browser.date_field(index: 1337)).to_not exist
44
+ expect(browser.date_field(xpath: "//input[@id='no_such_id']")).to_not exist
45
+ expect(browser.date_field(label: "bad label")).to_not exist
46
+ expect(browser.date_field(label: /bad label/)).to_not exist
47
+ end
48
+
49
+ it "raises TypeError when 'what' argument is invalid" do
50
+ expect { browser.date_field(id: 3.14).exists? }.to raise_error(TypeError)
51
+ end
52
+ end
53
+
54
+ # Attribute methods
55
+ describe "#id" do
56
+ it "returns the id attribute if the date field exists" do
57
+ expect(browser.date_field(name: 'html5_date').id).to eq "html5_date"
58
+ end
59
+
60
+ it "raises UnknownObjectException if the date field doesn't exist" do
61
+ expect { browser.date_field(index: 1337).id }.to raise_unknown_object_exception
62
+ end
63
+ end
64
+
65
+ describe "#name" do
66
+ it "returns the name attribute if the date field exists" do
67
+ expect(browser.date_field(id: 'html5_date').name).to eq "html5_date"
68
+ end
69
+
70
+ it "raises UnknownObjectException if the date field doesn't exist" do
71
+ expect { browser.date_field(index: 1337).name }.to raise_unknown_object_exception
72
+ end
73
+ end
74
+
75
+ describe "#type" do
76
+ it "returns the type attribute if the date field exists" do
77
+ expect(browser.date_field(id: 'html5_date').type).to eq "date"
78
+ end
79
+
80
+ it "raises UnknownObjectException if the date field doesn't exist" do
81
+ expect { browser.date_field(index: 1337).type }.to raise_unknown_object_exception
82
+ end
83
+ end
84
+
85
+ describe "#value" do
86
+ it "returns the value attribute if the date field exists" do
87
+ expect(browser.date_field(id: 'html5_date').value).to eq ""
88
+ end
89
+
90
+ it "raises UnknownObjectException if the date field doesn't exist" do
91
+ expect { browser.date_field(index: 1337).value }.to raise_unknown_object_exception
92
+ end
93
+ end
94
+
95
+ describe "#respond_to?" do
96
+ it "returns true for all attribute methods" do
97
+ expect(browser.date_field).to respond_to(:class_name)
98
+ expect(browser.date_field).to respond_to(:id)
99
+ expect(browser.date_field).to respond_to(:name)
100
+ expect(browser.date_field).to respond_to(:title)
101
+ expect(browser.date_field).to respond_to(:type)
102
+ expect(browser.date_field).to respond_to(:value)
103
+ end
104
+ end
105
+
106
+ # Access methods
107
+ describe "#enabled?" do
108
+ it "returns true for enabled date fields" do
109
+ expect(browser.browser.date_field(id: 'html5_date')).to be_enabled
110
+ end
111
+
112
+ it "raises UnknownObjectException if the date field doesn't exist" do
113
+ expect { browser.browser.date_field(id: 'no_such_id').enabled? }.to raise_unknown_object_exception
114
+ end
115
+ end
116
+
117
+ # Manipulation methods
118
+ describe "#value= " do
119
+ it "sets the value of the element" do
120
+ date = browser.date_field(id: 'html5_date')
121
+ date.value = Date.today
122
+ expect(Date.parse date.value).to eq Date.today
123
+ end
124
+
125
+ it "sets the value when accessed through the enclosing Form" do
126
+ date_field = browser.form(id: 'new_user').date_field(id: 'html5_date')
127
+ date_field.value = (Date.today)
128
+ expect(Date.parse(date_field.value)).to eq Date.today
129
+ end
130
+
131
+ it "raises UnknownObjectException if the date field doesn't exist" do
132
+ expect { browser.date_field(id: "no_such_id").value = Date.today }.to raise_unknown_object_exception
133
+ end
134
+
135
+ it "raises ArgumentError if using non-Date parameter" do
136
+ expect { browser.date_field(id: "no_such_id").value = "foo" }.to raise_exception ArgumentError
137
+ end
138
+ end
139
+
140
+ describe "#set!" do
141
+ it "sets the value of the element" do
142
+ date = browser.date_field(id: 'html5_date')
143
+ date.set!(Date.today)
144
+ expect(Date.parse date.value).to eq Date.today
145
+ end
146
+
147
+ it "sets the value when accessed through the enclosing Form" do
148
+ date_field = browser.form(id: 'new_user').date_field(id: 'html5_date')
149
+ date_field.set!(Date.today)
150
+ expect(Date.parse(date_field.value)).to eq Date.today
151
+ end
152
+
153
+ it "raises ArgumentError when no arguments are provided" do
154
+ expect { browser.date_field(id: 'html5_date').set! }.to raise_exception ArgumentError
155
+ end
156
+
157
+ it "raises UnknownObjectException if the date field doesn't exist" do
158
+ expect { browser.date_field(id: "no_such_id").set!(Date.today) }.to raise_unknown_object_exception
159
+ end
160
+ end
161
+
162
+ describe "#set" do
163
+ it "sets the value of the element" do
164
+ date = browser.date_field(id: 'html5_date')
165
+ date.set(Date.today)
166
+ expect(Date.parse date.value).to eq Date.today
167
+ end
168
+
169
+ it "sets the value when accessed through the enclosing Form" do
170
+ date_field = browser.form(id: 'new_user').date_field(id: 'html5_date')
171
+ date_field.set(Date.today)
172
+ expect(Date.parse(date_field.value)).to eq Date.today
173
+ end
174
+
175
+ it "raises ArgumentError when no arguments are provided" do
176
+ expect { browser.date_field(id: 'html5_date').set }.to raise_exception ArgumentError
177
+ end
178
+
179
+ it "raises UnknownObjectException if the date field doesn't exist" do
180
+ expect { browser.date_field(id: "no_such_id").set(Date.today) }.to raise_unknown_object_exception
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,44 @@
1
+ require "watirspec_helper"
2
+
3
+ describe "DateFields" do
4
+
5
+ before :each do
6
+ browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
7
+ end
8
+
9
+ describe "with selectors" do
10
+ it "returns the matching elements" do
11
+ expect(browser.date_fields(name: "html5_date").to_a).to eq [browser.date_field(name: "html5_date")]
12
+ end
13
+ end
14
+
15
+ describe "#length" do
16
+ it "returns the number of date_fields" do
17
+ expect(browser.date_fields.length).to eq 1
18
+ end
19
+ end
20
+
21
+ describe "#[]" do
22
+ it "returns the date_field at the given index" do
23
+ expect(browser.date_fields[0].id).to eq "html5_date"
24
+ end
25
+ end
26
+
27
+ describe "#each" do
28
+ it "iterates through date_fields correctly" do
29
+ count = 0
30
+
31
+ browser.date_fields.each_with_index do |c, index|
32
+ expect(c).to be_instance_of(Watir::DateField)
33
+ expect(c.name).to eq browser.date_field(index: index).name
34
+ expect(c.id).to eq browser.date_field(index: index).id
35
+ expect(c.value).to eq browser.date_field(index: index).value
36
+
37
+ count += 1
38
+ end
39
+
40
+ expect(count).to be > 0
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,193 @@
1
+ require "watirspec_helper"
2
+
3
+ describe "DateTimeField" do
4
+
5
+ before :each do
6
+ browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
7
+ end
8
+
9
+ # Exists method
10
+ describe "#exists?" do
11
+ it "returns true if the element exists" do
12
+ expect(browser.date_time_field(id: 'html5_datetime-local')).to exist
13
+ expect(browser.date_time_field(id: /html5_datetime-local/)).to exist
14
+ expect(browser.date_time_field(name: 'html5_datetime-local')).to exist
15
+ expect(browser.date_time_field(name: /html5_datetime-local/)).to exist
16
+ expect(browser.date_time_field(text: '')).to exist
17
+ expect(browser.date_time_field(text: //)).to exist
18
+ expect(browser.date_time_field(index: 0)).to exist
19
+ expect(browser.date_time_field(xpath: "//input[@id='html5_datetime-local']")).to exist
20
+ expect(browser.date_time_field(label: "HTML5 Datetime Local")).to exist
21
+ expect(browser.date_time_field(label: /Local$/)).to exist
22
+ end
23
+
24
+ it "returns the date-time field if given no args" do
25
+ expect(browser.date_time_field).to exist
26
+ end
27
+
28
+ bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1424984", :firefox do
29
+ it "respects date-time fields types" do
30
+ expect(browser.date_time_field.type).to eq('datetime-local')
31
+ end
32
+ end
33
+
34
+ it "returns false if the element does not exist" do
35
+ expect(browser.date_time_field(id: 'no_such_id')).to_not exist
36
+ expect(browser.date_time_field(id: /no_such_id/)).to_not exist
37
+ expect(browser.date_time_field(name: 'no_such_name')).to_not exist
38
+ expect(browser.date_time_field(name: /no_such_name/)).to_not exist
39
+ expect(browser.date_time_field(value: 'no_such_value')).to_not exist
40
+ expect(browser.date_time_field(value: /no_such_value/)).to_not exist
41
+ expect(browser.date_time_field(text: 'no_such_text')).to_not exist
42
+ expect(browser.date_time_field(text: /no_such_text/)).to_not exist
43
+ expect(browser.date_time_field(class: 'no_such_class')).to_not exist
44
+ expect(browser.date_time_field(class: /no_such_class/)).to_not exist
45
+ expect(browser.date_time_field(index: 1337)).to_not exist
46
+ expect(browser.date_time_field(xpath: "//input[@id='no_such_id']")).to_not exist
47
+ expect(browser.date_time_field(label: "bad label")).to_not exist
48
+ expect(browser.date_time_field(label: /bad label/)).to_not exist
49
+ end
50
+
51
+ it "raises TypeError when 'what' argument is invalid" do
52
+ expect { browser.date_time_field(id: 3.14).exists? }.to raise_error(TypeError)
53
+ end
54
+ end
55
+
56
+ # Attribute methods
57
+ describe "#id" do
58
+ it "returns the id attribute if the date-time field exists" do
59
+ expect(browser.date_time_field(name: 'html5_datetime-local').id).to eq "html5_datetime-local"
60
+ end
61
+
62
+ it "raises UnknownObjectException if the date-time field doesn't exist" do
63
+ expect { browser.date_time_field(index: 1337).id }.to raise_unknown_object_exception
64
+ end
65
+ end
66
+
67
+ describe "#name" do
68
+ it "returns the name attribute if the date-time field exists" do
69
+ expect(browser.date_time_field(id: 'html5_datetime-local').name).to eq "html5_datetime-local"
70
+ end
71
+
72
+ it "raises UnknownObjectException if the date-time field doesn't exist" do
73
+ expect { browser.date_time_field(index: 1337).name }.to raise_unknown_object_exception
74
+ end
75
+ end
76
+
77
+ describe "#type" do
78
+ bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1424984", :firefox do
79
+ it "returns the type attribute if the date-time field exists" do
80
+ expect(browser.date_time_field(id: 'html5_datetime-local').type).to eq "datetime-local"
81
+ end
82
+ end
83
+
84
+ it "raises UnknownObjectException if the date-time field doesn't exist" do
85
+ expect { browser.date_time_field(index: 1337).type }.to raise_unknown_object_exception
86
+ end
87
+ end
88
+
89
+ describe "#value" do
90
+ it "returns the value attribute if the date-time field exists" do
91
+ expect(browser.date_time_field(id: 'html5_datetime-local').value).to eq ""
92
+ end
93
+
94
+ it "raises UnknownObjectException if the date-time field doesn't exist" do
95
+ expect { browser.date_time_field(index: 1337).value }.to raise_unknown_object_exception
96
+ end
97
+ end
98
+
99
+ describe "#respond_to?" do
100
+ it "returns true for all attribute methods" do
101
+ expect(browser.date_time_field).to respond_to(:class_name)
102
+ expect(browser.date_time_field).to respond_to(:id)
103
+ expect(browser.date_time_field).to respond_to(:name)
104
+ expect(browser.date_time_field).to respond_to(:title)
105
+ expect(browser.date_time_field).to respond_to(:type)
106
+ expect(browser.date_time_field).to respond_to(:value)
107
+ end
108
+ end
109
+
110
+ # Access methods
111
+ describe "#enabled?" do
112
+ it "returns true for enabled date-time fields" do
113
+ expect(browser.browser.date_time_field(id: 'html5_datetime-local')).to be_enabled
114
+ end
115
+
116
+ it "raises UnknownObjectException if the date-time field doesn't exist" do
117
+ expect { browser.browser.date_time_field(id: 'no_such_id').enabled? }.to raise_unknown_object_exception
118
+ end
119
+ end
120
+
121
+ # Manipulation methods
122
+ describe "#value= " do
123
+ it "sets the value of the element" do
124
+ date_time = DateTime.now
125
+ date_time_field = browser.date_time_field(id: 'html5_datetime-local')
126
+ date_time_field.value = date_time
127
+ expect(DateTime.parse(date_time_field.value).strftime("%Y-%m-%dT%H:%M")).to eq date_time.strftime("%Y-%m-%dT%H:%M")
128
+ end
129
+
130
+ it "sets the value when accessed through the enclosing Form" do
131
+ date_time = DateTime.now
132
+ date_time_field = browser.form(id: 'new_user').date_time_field(id: 'html5_datetime-local')
133
+ date_time_field.value = date_time
134
+ expect(DateTime.parse(date_time_field.value).strftime("%Y-%m-%dT%H:%M")).to eq date_time.strftime("%Y-%m-%dT%H:%M")
135
+ end
136
+
137
+ it "raises UnknownObjectException if the date-time field doesn't exist" do
138
+ expect { browser.date_time_field(id: "no_such_id").value = DateTime.now }.to raise_unknown_object_exception
139
+ end
140
+
141
+ it "raises ArgumentError if using non-Date parameter" do
142
+ expect { browser.date_time_field(id: "no_such_id").value = "foo" }.to raise_exception ArgumentError
143
+ end
144
+ end
145
+
146
+ describe "#set!" do
147
+ it "sets the value of the element" do
148
+ date_time = DateTime.now
149
+ date_time_field = browser.date_time_field(id: 'html5_datetime-local')
150
+ date_time_field.set! date_time
151
+ expect(DateTime.parse(date_time_field.value).strftime("%Y-%m-%dT%H:%M")).to eq date_time.strftime("%Y-%m-%dT%H:%M")
152
+ end
153
+
154
+ it "sets the value when accessed through the enclosing Form" do
155
+ date_time = DateTime.now
156
+ date_time_field = browser.form(id: 'new_user').date_time_field(id: 'html5_datetime-local')
157
+ date_time_field.set! date_time
158
+ expect(DateTime.parse(date_time_field.value).strftime("%Y-%m-%dT%H:%M")).to eq date_time.strftime("%Y-%m-%dT%H:%M")
159
+ end
160
+
161
+ it "raises ArgumentError when no arguments are provided" do
162
+ expect { browser.date_time_field(id: 'html5_datetime-local').set! }.to raise_exception ArgumentError
163
+ end
164
+
165
+ it "raises UnknownObjectException if the date-time field doesn't exist" do
166
+ expect { browser.date_time_field(id: "no_such_id").set!(DateTime.now) }.to raise_unknown_object_exception
167
+ end
168
+ end
169
+
170
+ describe "#set" do
171
+ it "sets the value of the element" do
172
+ date_time = DateTime.now
173
+ date_time_field = browser.date_time_field(id: 'html5_datetime-local')
174
+ date_time_field.set(date_time)
175
+ expect(DateTime.parse(date_time_field.value).strftime("%Y-%m-%dT%H:%M")).to eq date_time.strftime("%Y-%m-%dT%H:%M")
176
+ end
177
+
178
+ it "sets the value when accessed through the enclosing Form" do
179
+ date_time = DateTime.now
180
+ date_time_field = browser.form(id: 'new_user').date_time_field(id: 'html5_datetime-local')
181
+ date_time_field.set date_time
182
+ expect(DateTime.parse(date_time_field.value).strftime("%Y-%m-%dT%H:%M")).to eq date_time.strftime("%Y-%m-%dT%H:%M")
183
+ end
184
+
185
+ it "raises ArgumentError when no arguments are provided" do
186
+ expect { browser.date_time_field(id: 'html5_datetime-local').set }.to raise_exception ArgumentError
187
+ end
188
+
189
+ it "raises UnknownObjectException if the date-time field doesn't exist" do
190
+ expect { browser.date_time_field(id: "no_such_id").set(DateTime.now) }.to raise_unknown_object_exception
191
+ end
192
+ end
193
+ end
@@ -0,0 +1,44 @@
1
+ require "watirspec_helper"
2
+
3
+ describe "DateTimeFields" do
4
+
5
+ before :each do
6
+ browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
7
+ end
8
+
9
+ describe "with selectors" do
10
+ it "returns the matching elements" do
11
+ expect(browser.date_time_fields(name: "html5_datetime-local").to_a).to eq [browser.date_time_field(name: "html5_datetime-local")]
12
+ end
13
+ end
14
+
15
+ describe "#length" do
16
+ it "returns the number of date_time_fields" do
17
+ expect(browser.date_time_fields.length).to eq 1
18
+ end
19
+ end
20
+
21
+ describe "#[]" do
22
+ it "returns the date_time_field at the given index" do
23
+ expect(browser.date_time_fields[0].id).to eq "html5_datetime-local"
24
+ end
25
+ end
26
+
27
+ describe "#each" do
28
+ it "iterates through date_time_fields correctly" do
29
+ count = 0
30
+
31
+ browser.date_time_fields.each_with_index do |c, index|
32
+ expect(c).to be_instance_of(Watir::DateTimeField)
33
+ expect(c.name).to eq browser.date_time_field(index: index).name
34
+ expect(c.id).to eq browser.date_time_field(index: index).id
35
+ expect(c.value).to eq browser.date_time_field(index: index).value
36
+
37
+ count += 1
38
+ end
39
+
40
+ expect(count).to be > 0
41
+ end
42
+ end
43
+
44
+ end
@@ -11,13 +11,15 @@ describe "IFrame" do
11
11
  end
12
12
 
13
13
  not_compliant_on :safari do
14
- it "handles crossframe javascript" do
15
- browser.goto WatirSpec.url_for("iframes.html")
16
-
17
- expect(browser.iframe(id: "iframe_1").text_field(name: 'senderElement').value).to eq 'send_this_value'
18
- expect(browser.iframe(id: "iframe_2").text_field(name: 'recieverElement').value).to eq 'old_value'
19
- browser.iframe(id: "iframe_1").button(id: 'send').click
20
- expect(browser.iframe(id: "iframe_2").text_field(name: 'recieverElement').value).to eq 'send_this_value'
14
+ bug "Firefox 58 broke this, apperas to be working in Nightly", %i(firefox linux) do
15
+ it "handles crossframe javascript" do
16
+ browser.goto WatirSpec.url_for("iframes.html")
17
+
18
+ expect(browser.iframe(id: "iframe_1").text_field(name: 'senderElement').value).to eq 'send_this_value'
19
+ expect(browser.iframe(id: "iframe_2").text_field(name: 'recieverElement').value).to eq 'old_value'
20
+ browser.iframe(id: "iframe_1").button(id: 'send').click
21
+ expect(browser.iframe(id: "iframe_2").text_field(name: 'recieverElement').value).to eq 'send_this_value'
22
+ end
21
23
  end
22
24
  end
23
25
 
@@ -110,7 +112,7 @@ describe "IFrame" do
110
112
  it "returns true if the iframe present" do
111
113
  expect(browser.iframe(id: "iframe_1")).to be_present
112
114
  end
113
-
115
+
114
116
  it "returns false if the iframe is not present" do
115
117
  expect(browser.iframe(id: "no_such_id")).not_to be_present
116
118
  end
@@ -161,7 +163,7 @@ describe "IFrame" do
161
163
  end
162
164
 
163
165
  it 'will suggest looking in an iframe when iframes exist' do
164
- expect {browser.text_field(name: 'senderElement').set('no') }.to raise_unknown_object_exception('Maybe look in an iframe?')
166
+ expect { browser.text_field(name: 'senderElement').set('no') }.to raise_unknown_object_exception('Maybe look in an iframe?')
165
167
  end
166
168
 
167
169
  describe "#execute_script" do
@@ -14,7 +14,7 @@ describe "TextFields" do
14
14
 
15
15
  describe "#length" do
16
16
  it "returns the number of text fields" do
17
- expect(browser.text_fields.length).to eq 19
17
+ expect(browser.text_fields.length).to eq 17
18
18
  end
19
19
  end
20
20
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'watir'
5
- s.version = '6.10.2'
5
+ s.version = '6.10.3'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ['Alex Rodionov', 'Titus Fortner']
8
8
  s.email = ['p0deje@gmail.com', 'titusfortner@gmail.com']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.10.2
4
+ version: 6.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rodionov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-13 00:00:00.000000000 Z
12
+ date: 2018-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: selenium-webdriver
@@ -234,6 +234,8 @@ files:
234
234
  - lib/watir/elements/button.rb
235
235
  - lib/watir/elements/cell.rb
236
236
  - lib/watir/elements/checkbox.rb
237
+ - lib/watir/elements/date_field.rb
238
+ - lib/watir/elements/date_time_field.rb
237
239
  - lib/watir/elements/dlist.rb
238
240
  - lib/watir/elements/element.rb
239
241
  - lib/watir/elements/file_field.rb
@@ -354,6 +356,10 @@ files:
354
356
  - spec/watirspec/elements/checkbox_spec.rb
355
357
  - spec/watirspec/elements/checkboxes_spec.rb
356
358
  - spec/watirspec/elements/collections_spec.rb
359
+ - spec/watirspec/elements/date_field_spec.rb
360
+ - spec/watirspec/elements/date_fields_spec.rb
361
+ - spec/watirspec/elements/date_time_field_spec.rb
362
+ - spec/watirspec/elements/date_time_fields_spec.rb
357
363
  - spec/watirspec/elements/dd_spec.rb
358
364
  - spec/watirspec/elements/dds_spec.rb
359
365
  - spec/watirspec/elements/del_spec.rb
@@ -519,7 +525,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
519
525
  version: '0'
520
526
  requirements: []
521
527
  rubyforge_project: watir
522
- rubygems_version: 2.6.11
528
+ rubygems_version: 2.7.3
523
529
  signing_key:
524
530
  specification_version: 4
525
531
  summary: Watir powered by Selenium
@@ -550,6 +556,10 @@ test_files:
550
556
  - spec/watirspec/elements/checkbox_spec.rb
551
557
  - spec/watirspec/elements/checkboxes_spec.rb
552
558
  - spec/watirspec/elements/collections_spec.rb
559
+ - spec/watirspec/elements/date_field_spec.rb
560
+ - spec/watirspec/elements/date_fields_spec.rb
561
+ - spec/watirspec/elements/date_time_field_spec.rb
562
+ - spec/watirspec/elements/date_time_fields_spec.rb
553
563
  - spec/watirspec/elements/dd_spec.rb
554
564
  - spec/watirspec/elements/dds_spec.rb
555
565
  - spec/watirspec/elements/del_spec.rb