testcentricity_web 3.2.6 → 3.2.7

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
  SHA256:
3
- metadata.gz: 31b3ef470818525ef0b59b59116de2833f47266718d0aab4f357189899d00e8f
4
- data.tar.gz: 78e48e5d3528431f1b73d306179d5eb49ad3b0780ec5427cc1aa131f1e68ac79
3
+ metadata.gz: 4cf0527341127362a18f4192a2c5d0656349e57030dd660689b163ab2544732e
4
+ data.tar.gz: aaa6fd6abd7855826917a8e64c1bdb4b15ea66178186e639fefcb5b97d339560
5
5
  SHA512:
6
- metadata.gz: 4d9f54a051be96846d2d3dfcca8c7182067c346ba6b2c5d0160f8225c25e1ef4ac4768519fd1e3b41e886c37e7b877d989cd49e1ad1930e7ecff1ab8cd644fd0
7
- data.tar.gz: 07bbceeeb3af72e2bc9b8d8a3e21f31b25a3f922956a76719048e7dde67e071cd5baa37126cd3557b7f57722389781af25850234a85f29ddb09bf06fa0eab16f
6
+ metadata.gz: a4b1322ea1c79052e35f94ebd5a6b3b308acb62a0f85d64f0d462e93c5aa1f37fe62ffeb7e01b9b21e3ea763b92933987fc65fa2892088c784dae0a9434867dc
7
+ data.tar.gz: a398d3e9052b7f05235bca6aa73888513f05293802d2901b59ea6704c8b32cabcb078d173f04294b65ac613aa42c3dff07faf28a04cc94019115f431a04a9bf3
@@ -1,6 +1,15 @@
1
1
  # CHANGELOG
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [3.2.7] - 05-FEB-2020
5
+
6
+ ### Added
7
+ * Added `Audio.crossorigin` and `Video.crossorigin` methods.
8
+ * Added `Audio.preload` and `Video.preload` methods.
9
+ * Added `Video.poster` method.
10
+ * Updated `PageObject.verify_ui_states` and `PageSection.verify_ui_states` methods to support verification of the
11
+ `crossorigin`, `preload`, and `poster` properties.
12
+
4
13
  ## [3.2.6] - 31-JAN-2020
5
14
 
6
15
  ### Changed
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- testcentricity_web (3.2.6)
4
+ testcentricity_web (3.2.7)
5
5
  appium_lib
6
6
  browserstack-local
7
7
  capybara (>= 3.1, < 4)
@@ -32,6 +32,7 @@ require 'testcentricity_web/web_elements/list'
32
32
  require 'testcentricity_web/web_elements/table'
33
33
  require 'testcentricity_web/web_elements/textfield'
34
34
  require 'testcentricity_web/web_elements/range'
35
+ require 'testcentricity_web/web_elements/media'
35
36
  require 'testcentricity_web/web_elements/audio'
36
37
  require 'testcentricity_web/web_elements/video'
37
38
  require 'testcentricity_web/web_elements/cell_element'
@@ -1,3 +1,3 @@
1
1
  module TestCentricityWeb
2
- VERSION = '3.2.6'
2
+ VERSION = '3.2.7'
3
3
  end
@@ -111,6 +111,12 @@ module TestCentricity
111
111
  ui_object.ready_state
112
112
  when :volume
113
113
  ui_object.volume
114
+ when :crossorigin
115
+ ui_object.crossorigin
116
+ when :preload
117
+ ui_object.preload
118
+ when :poster
119
+ ui_object.poster
114
120
  when :options, :items, :list_items
115
121
  ui_object.get_list_items
116
122
  when :optioncount, :itemcount
@@ -1,255 +1,8 @@
1
1
  module TestCentricity
2
- class Audio < UIElement
2
+ class Audio < Media
3
3
  def initialize(name, parent, locator, context)
4
4
  super
5
5
  @type = :audio
6
6
  end
7
-
8
- # Return audio autoplay property
9
- #
10
- # @return [Boolean]
11
- # @example
12
- # audio_player.autoplay?
13
- #
14
- def autoplay?
15
- obj, = find_element(visible = :all)
16
- object_not_found_exception(obj, :audio)
17
- state = obj.native.attribute('autoplay')
18
- state.boolean? ? state : state == 'true'
19
- end
20
-
21
- # Return audio ended property
22
- #
23
- # @return [Boolean]
24
- # @example
25
- # audio_player.ended?
26
- #
27
- def ended?
28
- obj, = find_element(visible = :all)
29
- object_not_found_exception(obj, :audio)
30
- state = obj.native.attribute('ended')
31
- state.boolean? ? state : state == 'true'
32
- end
33
-
34
- # Return audio controls property
35
- #
36
- # @return [Boolean]
37
- # @example
38
- # audio_player.controls?
39
- #
40
- def controls?
41
- obj, = find_element(visible = :all)
42
- object_not_found_exception(obj, :audio)
43
- state = obj.native.attribute('controls')
44
- state.boolean? ? state : state == 'true'
45
- end
46
-
47
- # Return audio loop property
48
- #
49
- # @return [Boolean]
50
- # @example
51
- # audio_player.loop?
52
- #
53
- def loop?
54
- obj, = find_element(visible = :all)
55
- object_not_found_exception(obj, :audio)
56
- loop_state = obj.native.attribute('loop')
57
- loop_state.boolean? ? loop_state : loop_state == 'true'
58
- end
59
-
60
- # Return audio muted property
61
- #
62
- # @return [Boolean]
63
- # @example
64
- # audio_player.muted?
65
- #
66
- def muted?
67
- obj, = find_element(visible = :all)
68
- object_not_found_exception(obj, :audio)
69
- mute_state = obj.native.attribute('muted')
70
- mute_state.boolean? ? mute_state : mute_state == 'true'
71
- end
72
-
73
- # Return audio defaultMuted property
74
- #
75
- # @return [Boolean]
76
- # @example
77
- # audio_player.default_muted?
78
- #
79
- def default_muted?
80
- obj, = find_element(visible = :all)
81
- object_not_found_exception(obj, :audio)
82
- mute_state = obj.native.attribute('defaultMuted')
83
- mute_state.boolean? ? mute_state : mute_state == 'true'
84
- end
85
-
86
- # Return audio paused property
87
- #
88
- # @return [Boolean]
89
- # @example
90
- # audio_player.paused?
91
- #
92
- def paused?
93
- obj, = find_element(visible = :all)
94
- object_not_found_exception(obj, :audio)
95
- paused_state = obj.native.attribute('paused')
96
- paused_state.boolean? ? paused_state : paused_state == 'true'
97
- end
98
-
99
- # Return audio seeking property
100
- #
101
- # @return [Boolean]
102
- # @example
103
- # audio_player.seeking?
104
- #
105
- def seeking?
106
- obj, = find_element(visible = :all)
107
- object_not_found_exception(obj, :audio)
108
- state = obj.native.attribute('seeking')
109
- state.boolean? ? state : state == 'true'
110
- end
111
-
112
- # Return audio src property
113
- #
114
- # @return [String] value of src property
115
- # @example
116
- # src_value = audio_player.src
117
- #
118
- def src
119
- obj, = find_element(visible = :all)
120
- object_not_found_exception(obj, :audio)
121
- obj.native.attribute('src')
122
- end
123
-
124
- # Return audio currentTime property
125
- #
126
- # @return [Float] current playback position in seconds
127
- # @example
128
- # current_player_time = audio_player.current_time
129
- #
130
- def current_time
131
- obj, = find_element(visible = :all)
132
- object_not_found_exception(obj, :audio)
133
- obj.native.attribute('currentTime').to_f
134
- end
135
-
136
- # Return audio defaultPlaybackRate property
137
- #
138
- # @return [Integer or Float] default playback speed
139
- # @example
140
- # default_speed = audio_player.default_playback_rate
141
- #
142
- def default_playback_rate
143
- obj, = find_element(visible = :all)
144
- object_not_found_exception(obj, :audio)
145
- obj.native.attribute('defaultPlaybackRate')
146
- end
147
-
148
- # Return audio duration property
149
- #
150
- # @return [Float] duration of audio
151
- # @example
152
- # how_long = audio_player.duration
153
- #
154
- def duration
155
- obj, = find_element(visible = :all)
156
- object_not_found_exception(obj, :audio)
157
- obj.native.attribute('duration').to_f
158
- end
159
-
160
- # Return audio playbackRate property
161
- #
162
- # @return [Integer or Float] current playback speed
163
- # @example
164
- # playback_speed = audio_player.playback_rate
165
- #
166
- def playback_rate
167
- obj, = find_element(visible = :all)
168
- object_not_found_exception(obj, :audio)
169
- obj.native.attribute('playbackRate')
170
- end
171
-
172
- # Return audio readyState property
173
- #
174
- # @return [Integer] audio ready state
175
- # 0 = HAVE_NOTHING - no information whether or not the audio/video is ready
176
- # 1 = HAVE_METADATA - metadata for the audio/video is ready
177
- # 2 = HAVE_CURRENT_DATA - data for the current playback position is available, but not enough data to play next frame/millisecond
178
- # 3 = HAVE_FUTURE_DATA - data for the current and at least the next frame is available
179
- # 4 = HAVE_ENOUGH_DATA - enough data available to start playing
180
- # @example
181
- # audio_status = audio_player.ready_state
182
- #
183
- def ready_state
184
- obj, = find_element(visible = :all)
185
- object_not_found_exception(obj, :audio)
186
- obj.native.attribute('readyState').to_i
187
- end
188
-
189
- # Wait until the audio object's readyState value equals the specified value, or until the specified wait time has expired. If the wait
190
- # time is nil, then the wait time will be Capybara.default_max_wait_time.
191
- #
192
- # @param value [Integer] value expected
193
- # @param seconds [Integer or Float] wait time in seconds
194
- # @example
195
- # audio_player.wait_until_ready_state_is(4, 5)
196
- #
197
- def wait_until_ready_state_is(value, seconds = nil, post_exception = true)
198
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
199
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
200
- wait.until { ready_state == value }
201
- rescue StandardError
202
- if post_exception
203
- raise "Ready state of Audio #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_value == value
204
- else
205
- ready_state == value
206
- end
207
- end
208
-
209
- # Return audio volume property
210
- #
211
- # @return [Float] audio volume setting
212
- # @example
213
- # volume_level = audio_player.volume
214
- #
215
- def volume
216
- obj, = find_element(visible = :all)
217
- object_not_found_exception(obj, :audio)
218
- obj.native.attribute('volume').to_f
219
- end
220
-
221
- # Set the audio currentTime property
222
- #
223
- # @param value [Float] time in seconds
224
- # @example
225
- # audio_player.current_time = 1.5
226
- #
227
- def current_time=(value)
228
- obj, = find_element(visible = :all)
229
- object_not_found_exception(obj, nil)
230
- page.execute_script('arguments[0].currentTime = arguments[1]', obj, value)
231
- end
232
-
233
- # Play the audio
234
- #
235
- # @example
236
- # audio_player.play
237
- #
238
- def play
239
- obj, = find_element(visible = :all)
240
- object_not_found_exception(obj, nil)
241
- page.execute_script('arguments[0].play()', obj)
242
- end
243
-
244
- # Pause the audio
245
- #
246
- # @example
247
- # audio_player.pause
248
- #
249
- def pause
250
- obj, = find_element(visible = :all)
251
- object_not_found_exception(obj, nil)
252
- page.execute_script('arguments[0].pause()', obj)
253
- end
254
7
  end
255
8
  end
@@ -0,0 +1,274 @@
1
+ module TestCentricity
2
+ class Media < UIElement
3
+ # Return media autoplay property
4
+ #
5
+ # @return [Boolean]
6
+ # @example
7
+ # media_player.autoplay?
8
+ #
9
+ def autoplay?
10
+ obj, = find_element(visible = :all)
11
+ object_not_found_exception(obj, @type)
12
+ state = obj.native.attribute('autoplay')
13
+ state.boolean? ? state : state == 'true'
14
+ end
15
+
16
+ # Return media ended property
17
+ #
18
+ # @return [Boolean]
19
+ # @example
20
+ # media_player.ended?
21
+ #
22
+ def ended?
23
+ obj, = find_element(visible = :all)
24
+ object_not_found_exception(obj, @type)
25
+ state = obj.native.attribute('ended')
26
+ state.boolean? ? state : state == 'true'
27
+ end
28
+
29
+ # Return media controls property
30
+ #
31
+ # @return [Boolean]
32
+ # @example
33
+ # media_player.controls?
34
+ #
35
+ def controls?
36
+ obj, = find_element(visible = :all)
37
+ object_not_found_exception(obj, @type)
38
+ state = obj.native.attribute('controls')
39
+ state.boolean? ? state : state == 'true'
40
+ end
41
+
42
+ # Return media loop property
43
+ #
44
+ # @return [Boolean]
45
+ # @example
46
+ # media_player.loop?
47
+ #
48
+ def loop?
49
+ obj, = find_element(visible = :all)
50
+ object_not_found_exception(obj, @type)
51
+ loop_state = obj.native.attribute('loop')
52
+ loop_state.boolean? ? loop_state : loop_state == 'true'
53
+ end
54
+
55
+ # Return media muted property
56
+ #
57
+ # @return [Boolean]
58
+ # @example
59
+ # media_player.muted?
60
+ #
61
+ def muted?
62
+ obj, = find_element(visible = :all)
63
+ object_not_found_exception(obj, @type)
64
+ mute_state = obj.native.attribute('muted')
65
+ mute_state.boolean? ? mute_state : mute_state == 'true'
66
+ end
67
+
68
+ # Return media defaultMuted property
69
+ #
70
+ # @return [Boolean]
71
+ # @example
72
+ # media_player.default_muted?
73
+ #
74
+ def default_muted?
75
+ obj, = find_element(visible = :all)
76
+ object_not_found_exception(obj, @type)
77
+ mute_state = obj.native.attribute('defaultMuted')
78
+ mute_state.boolean? ? mute_state : mute_state == 'true'
79
+ end
80
+
81
+ # Return media paused property
82
+ #
83
+ # @return [Boolean]
84
+ # @example
85
+ # media_player.paused?
86
+ #
87
+ def paused?
88
+ obj, = find_element(visible = :all)
89
+ object_not_found_exception(obj, @type)
90
+ paused_state = obj.native.attribute('paused')
91
+ paused_state.boolean? ? paused_state : paused_state == 'true'
92
+ end
93
+
94
+ # Return media seeking property
95
+ #
96
+ # @return [Boolean]
97
+ # @example
98
+ # media_player.seeking?
99
+ #
100
+ def seeking?
101
+ obj, = find_element(visible = :all)
102
+ object_not_found_exception(obj, @type)
103
+ state = obj.native.attribute('seeking')
104
+ state.boolean? ? state : state == 'true'
105
+ end
106
+
107
+ # Return media src property
108
+ #
109
+ # @return [String] value of src property
110
+ # @example
111
+ # src_value = media_player.src
112
+ #
113
+ def src
114
+ obj, = find_element(visible = :all)
115
+ object_not_found_exception(obj, @type)
116
+ obj.native.attribute('src')
117
+ end
118
+
119
+ # Return media currentTime property
120
+ #
121
+ # @return [Float] current playback position in seconds
122
+ # @example
123
+ # current_player_time = media_player.current_time
124
+ #
125
+ def current_time
126
+ obj, = find_element(visible = :all)
127
+ object_not_found_exception(obj, @type)
128
+ obj.native.attribute('currentTime').to_f
129
+ end
130
+
131
+ # Return media defaultPlaybackRate property
132
+ #
133
+ # @return [Integer or Float] default playback speed
134
+ # @example
135
+ # default_speed = media_player.default_playback_rate
136
+ #
137
+ def default_playback_rate
138
+ obj, = find_element(visible = :all)
139
+ object_not_found_exception(obj, @type)
140
+ obj.native.attribute('defaultPlaybackRate')
141
+ end
142
+
143
+ # Return media duration property
144
+ #
145
+ # @return [Float] duration of media
146
+ # @example
147
+ # how_long = media_player.duration
148
+ #
149
+ def duration
150
+ obj, = find_element(visible = :all)
151
+ object_not_found_exception(obj, @type)
152
+ obj.native.attribute('duration').to_f
153
+ end
154
+
155
+ # Return media playbackRate property
156
+ #
157
+ # @return [Integer or Float] current playback speed
158
+ # @example
159
+ # playback_speed = media_player.playback_rate
160
+ #
161
+ def playback_rate
162
+ obj, = find_element(visible = :all)
163
+ object_not_found_exception(obj, @type)
164
+ obj.native.attribute('playbackRate')
165
+ end
166
+
167
+ # Return media readyState property
168
+ #
169
+ # @return [Integer] media ready state
170
+ # 0 = HAVE_NOTHING - no information whether or not the audio/video is ready
171
+ # 1 = HAVE_METADATA - metadata for the audio/video is ready
172
+ # 2 = HAVE_CURRENT_DATA - data for the current playback position is available, but not enough data to play next frame/millisecond
173
+ # 3 = HAVE_FUTURE_DATA - data for the current and at least the next frame is available
174
+ # 4 = HAVE_ENOUGH_DATA - enough data available to start playing
175
+ # @example
176
+ # media_status = media_player.ready_state
177
+ #
178
+ def ready_state
179
+ obj, = find_element(visible = :all)
180
+ object_not_found_exception(obj, @type)
181
+ obj.native.attribute('readyState').to_i
182
+ end
183
+
184
+ # Wait until the media object's readyState value equals the specified value, or until the specified wait time has expired. If the wait
185
+ # time is nil, then the wait time will be Capybara.default_max_wait_time.
186
+ #
187
+ # @param value [Integer] value expected
188
+ # @param seconds [Integer or Float] wait time in seconds
189
+ # @example
190
+ # media_player.wait_until_ready_state_is(4, 5)
191
+ #
192
+ def wait_until_ready_state_is(value, seconds = nil, post_exception = true)
193
+ timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
194
+ wait = Selenium::WebDriver::Wait.new(timeout: timeout)
195
+ wait.until { ready_state == value }
196
+ rescue StandardError
197
+ if post_exception
198
+ raise "Ready state of Audio #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_value == value
199
+ else
200
+ ready_state == value
201
+ end
202
+ end
203
+
204
+ # Return media volume property
205
+ #
206
+ # @return [Float] media volume setting
207
+ # @example
208
+ # volume_level = media_player.volume
209
+ #
210
+ def volume
211
+ obj, = find_element(visible = :all)
212
+ object_not_found_exception(obj, @type)
213
+ obj.native.attribute('volume').to_f
214
+ end
215
+
216
+ # Set the media currentTime property
217
+ #
218
+ # @param value [Float] time in seconds
219
+ # @example
220
+ # media_player.current_time = 1.5
221
+ #
222
+ def current_time=(value)
223
+ obj, = find_element(visible = :all)
224
+ object_not_found_exception(obj, @type)
225
+ page.execute_script('arguments[0].currentTime = arguments[1]', obj, value)
226
+ end
227
+
228
+ # Play the media
229
+ #
230
+ # @example
231
+ # media_player.play
232
+ #
233
+ def play
234
+ obj, = find_element(visible = :all)
235
+ object_not_found_exception(obj, @type)
236
+ page.execute_script('arguments[0].play()', obj)
237
+ end
238
+
239
+ # Pause the media
240
+ #
241
+ # @example
242
+ # media_player.pause
243
+ #
244
+ def pause
245
+ obj, = find_element(visible = :all)
246
+ object_not_found_exception(obj, @type)
247
+ page.execute_script('arguments[0].pause()', obj)
248
+ end
249
+
250
+ # Return media crossorigin property
251
+ #
252
+ # @return crossorigin value
253
+ # @example
254
+ # with_creds = media_player.crossorigin == 'use-credentials'
255
+ #
256
+ def crossorigin
257
+ obj, = find_element
258
+ object_not_found_exception(obj, @type)
259
+ obj.native.attribute('crossorigin')
260
+ end
261
+
262
+ # Return media preload property
263
+ #
264
+ # @return preload value
265
+ # @example
266
+ # preload = media_player.preload
267
+ #
268
+ def preload
269
+ obj, = find_element
270
+ object_not_found_exception(obj, @type)
271
+ obj.native.attribute('preload')
272
+ end
273
+ end
274
+ end
@@ -119,7 +119,7 @@ module TestCentricity
119
119
  begin
120
120
  obj.click
121
121
  rescue StandardError
122
- obj.click_at(10, 10) unless Capybara.current_driver == :poltergeist
122
+ obj.click_at(10, 10)
123
123
  end
124
124
  end
125
125
 
@@ -194,29 +194,9 @@ module TestCentricity
194
194
  # remember_me_checkbox.visible?
195
195
  #
196
196
  def visible?
197
- obj, type = find_object
197
+ obj, = find_element
198
198
  exists = obj
199
- invisible = false
200
- if type == :css
201
- Capybara.using_wait_time 0.1 do
202
- # is object itself hidden with .ui-helper-hidden class?
203
- self_hidden = page.has_css?("#{@locator}.ui-helper-hidden")
204
- # is parent of object hidden, thus hiding the object?
205
- parent_hidden = page.has_css?(".ui-helper-hidden > #{@locator}")
206
- # is grandparent of object, or any other ancestor, hidden?
207
- other_ancestor_hidden = page.has_css?(".ui-helper-hidden * #{@locator}")
208
- # if any of the above conditions are true, then object is invisible
209
- invisible = self_hidden || parent_hidden || other_ancestor_hidden
210
- end
211
- else
212
- invisible = !obj.visible? if exists
213
- end
214
- # the object is visible if it exists and it is not invisible
215
- if exists && !invisible
216
- true
217
- else
218
- false
219
- end
199
+ exists ? obj.visible? : false
220
200
  end
221
201
 
222
202
  # Is UI object hidden (not visible)?
@@ -1,223 +1,10 @@
1
1
  module TestCentricity
2
- class Video < UIElement
2
+ class Video < Media
3
3
  def initialize(name, parent, locator, context)
4
4
  super
5
5
  @type = :video
6
6
  end
7
7
 
8
- # Return video autoplay property
9
- #
10
- # @return [Boolean]
11
- # @example
12
- # video_player.autoplay?
13
- #
14
- def autoplay?
15
- obj, = find_element
16
- object_not_found_exception(obj, nil)
17
- state = obj.native.attribute('autoplay')
18
- state.boolean? ? state : state == 'true'
19
- end
20
-
21
- # Return video ended property
22
- #
23
- # @return [Boolean]
24
- # @example
25
- # video_player.ended?
26
- #
27
- def ended?
28
- obj, = find_element
29
- object_not_found_exception(obj, nil)
30
- state = obj.native.attribute('ended')
31
- state.boolean? ? state : state == 'true'
32
- end
33
-
34
- # Return video controls property
35
- #
36
- # @return [Boolean]
37
- # @example
38
- # video_player.controls?
39
- #
40
- def controls?
41
- obj, = find_element
42
- object_not_found_exception(obj, nil)
43
- state = obj.native.attribute('controls')
44
- state.boolean? ? state : state == 'true'
45
- end
46
-
47
- # Return video loop property
48
- #
49
- # @return [Boolean]
50
- # @example
51
- # video_player.loop?
52
- #
53
- def loop?
54
- obj, = find_element
55
- object_not_found_exception(obj, nil)
56
- loop_state = obj.native.attribute('loop')
57
- loop_state.boolean? ? loop_state : loop_state == 'true'
58
- end
59
-
60
- # Return video muted property
61
- #
62
- # @return [Boolean]
63
- # @example
64
- # video_player.muted?
65
- #
66
- def muted?
67
- obj, = find_element
68
- object_not_found_exception(obj, nil)
69
- mute_state = obj.native.attribute('muted')
70
- mute_state.boolean? ? mute_state : mute_state == 'true'
71
- end
72
-
73
- # Return video defaultMuted property
74
- #
75
- # @return [Boolean]
76
- # @example
77
- # video_player.default_muted?
78
- #
79
- def default_muted?
80
- obj, = find_element
81
- object_not_found_exception(obj, nil)
82
- mute_state = obj.native.attribute('defaultMuted')
83
- mute_state.boolean? ? mute_state : mute_state == 'true'
84
- end
85
-
86
- # Return video paused property
87
- #
88
- # @return [Boolean]
89
- # @example
90
- # video_player.paused?
91
- #
92
- def paused?
93
- obj, = find_element
94
- object_not_found_exception(obj, nil)
95
- paused_state = obj.native.attribute('paused')
96
- paused_state.boolean? ? paused_state : paused_state == 'true'
97
- end
98
-
99
- # Return video seeking property
100
- #
101
- # @return [Boolean]
102
- # @example
103
- # video_player.seeking?
104
- #
105
- def seeking?
106
- obj, = find_element
107
- object_not_found_exception(obj, nil)
108
- state = obj.native.attribute('seeking')
109
- state.boolean? ? state : state == 'true'
110
- end
111
-
112
- # Return video src property
113
- #
114
- # @return [String] value of src property
115
- # @example
116
- # src_value = video_player.src
117
- #
118
- def src
119
- obj, = find_element
120
- object_not_found_exception(obj, nil)
121
- obj.native.attribute('src')
122
- end
123
-
124
- # Return video currentTime property
125
- #
126
- # @return [Float] current playback position in seconds
127
- # @example
128
- # current_player_time = video_player.current_time
129
- #
130
- def current_time
131
- obj, = find_element
132
- object_not_found_exception(obj, nil)
133
- obj.native.attribute('currentTime').to_f
134
- end
135
-
136
- # Return video defaultPlaybackRate property
137
- #
138
- # @return [Integer or Float] default playback speed
139
- # @example
140
- # default_speed = video_player.default_playback_rate
141
- #
142
- def default_playback_rate
143
- obj, = find_element
144
- object_not_found_exception(obj, nil)
145
- obj.native.attribute('defaultPlaybackRate')
146
- end
147
-
148
- # Return video duration property
149
- #
150
- # @return [Float] duration of video
151
- # @example
152
- # how_long = video_player.duration
153
- #
154
- def duration
155
- obj, = find_element
156
- object_not_found_exception(obj, nil)
157
- obj.native.attribute('duration').to_f
158
- end
159
-
160
- # Return video playbackRate property
161
- #
162
- # @return [Integer or Float] current playback speed
163
- # @example
164
- # playback_speed = video_player.playback_rate
165
- #
166
- def playback_rate
167
- obj, = find_element
168
- object_not_found_exception(obj, nil)
169
- obj.native.attribute('playbackRate')
170
- end
171
-
172
- # Return video readyState property
173
- #
174
- # @return [Integer] video ready state
175
- # 0 = HAVE_NOTHING - no information whether or not the audio/video is ready
176
- # 1 = HAVE_METADATA - metadata for the audio/video is ready
177
- # 2 = HAVE_CURRENT_DATA - data for the current playback position is available, but not enough data to play next frame/millisecond
178
- # 3 = HAVE_FUTURE_DATA - data for the current and at least the next frame is available
179
- # 4 = HAVE_ENOUGH_DATA - enough data available to start playing
180
- # @example
181
- # vid_status = video_player.ready_state
182
- #
183
- def ready_state
184
- obj, = find_element
185
- object_not_found_exception(obj, nil)
186
- obj.native.attribute('readyState').to_i
187
- end
188
-
189
- # Wait until the video object's readyState value equals the specified value, or until the specified wait time has expired. If the wait
190
- # time is nil, then the wait time will be Capybara.default_max_wait_time.
191
- #
192
- # @param value [Integer] value expected
193
- # @param seconds [Integer or Float] wait time in seconds
194
- # @example
195
- # video_player.wait_until_ready_state_is(4, 5)
196
- #
197
- def wait_until_ready_state_is(value, seconds = nil, post_exception = true)
198
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
199
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
200
- wait.until { ready_state == value }
201
- rescue StandardError
202
- if post_exception
203
- raise "Ready state of Video #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_value == value
204
- else
205
- ready_state == value
206
- end
207
- end
208
-
209
- # Return video volume property
210
- #
211
- # @return [Float] video volume setting
212
- # @example
213
- # volume_level = video_player.volume
214
- #
215
- def volume
216
- obj, = find_element
217
- object_not_found_exception(obj, nil)
218
- obj.native.attribute('volume').to_f
219
- end
220
-
221
8
  # Return video Height property
222
9
  #
223
10
  # @return [Integer] video height
@@ -226,7 +13,7 @@ module TestCentricity
226
13
  #
227
14
  def video_height
228
15
  obj, = find_element
229
- object_not_found_exception(obj, nil)
16
+ object_not_found_exception(obj, :video)
230
17
  obj.native.attribute('videoHeight')
231
18
  end
232
19
 
@@ -238,42 +25,20 @@ module TestCentricity
238
25
  #
239
26
  def video_width
240
27
  obj, = find_element
241
- object_not_found_exception(obj, nil)
28
+ object_not_found_exception(obj, :video)
242
29
  obj.native.attribute('videoWidth')
243
30
  end
244
31
 
245
- # Set the video currentTime property
246
- #
247
- # @param value [Float] time in seconds
248
- # @example
249
- # video_player.current_time = 1.5
250
- #
251
- def current_time=(value)
252
- obj, = find_element
253
- object_not_found_exception(obj, nil)
254
- page.execute_script('arguments[0].currentTime = arguments[1]', obj, value)
255
- end
256
-
257
- # Play the video
258
- #
259
- # @example
260
- # video_player.play
261
- #
262
- def play
263
- obj, = find_element
264
- object_not_found_exception(obj, nil)
265
- page.execute_script('arguments[0].play()', obj)
266
- end
267
-
268
- # Pause the video
32
+ # Return video poster property
269
33
  #
34
+ # @return poster value
270
35
  # @example
271
- # video_player.pause
36
+ # poster = video_player.poster
272
37
  #
273
- def pause
38
+ def poster
274
39
  obj, = find_element
275
- object_not_found_exception(obj, nil)
276
- page.execute_script('arguments[0].pause()', obj)
40
+ object_not_found_exception(obj, :video)
41
+ obj.native.attribute('poster')
277
42
  end
278
43
  end
279
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testcentricity_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.6
4
+ version: 3.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - A.J. Mrozinski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-31 00:00:00.000000000 Z
11
+ date: 2020-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -289,6 +289,7 @@ files:
289
289
  - lib/testcentricity_web/web_elements/list_checkbox.rb
290
290
  - lib/testcentricity_web/web_elements/list_element.rb
291
291
  - lib/testcentricity_web/web_elements/list_radio.rb
292
+ - lib/testcentricity_web/web_elements/media.rb
292
293
  - lib/testcentricity_web/web_elements/radio.rb
293
294
  - lib/testcentricity_web/web_elements/range.rb
294
295
  - lib/testcentricity_web/web_elements/select_list.rb