Class: TestCentricity::Media
- Defined in:
- lib/testcentricity_web/web_elements/media.rb
Constant Summary
Constants inherited from UIElement
UIElement::CSS_SELECTORS, UIElement::XPATH_SELECTORS
Instance Attribute Summary
Attributes inherited from UIElement
#alt_locator, #base_object, #context, #locator, #locator_type, #name, #original_style, #parent, #type
Instance Method Summary collapse
-
#autoplay? ⇒ Boolean
Return media autoplay property.
-
#controls? ⇒ Boolean
Return media controls property.
-
#current_time ⇒ Float
Return media currentTime property.
-
#current_time=(value) ⇒ Object
Set the media currentTime property.
-
#default_muted? ⇒ Boolean
Return media defaultMuted property.
-
#default_playback_rate ⇒ Integer or Float
Return media defaultPlaybackRate property.
-
#duration ⇒ Float
Return media duration property.
-
#ended? ⇒ Boolean
Return media ended property.
-
#loop? ⇒ Boolean
Return media loop property.
-
#mute ⇒ Object
Mute the media's audio.
-
#muted? ⇒ Boolean
Return media muted property.
-
#pause ⇒ Object
Pause the media.
-
#paused? ⇒ Boolean
Return media paused property.
-
#play ⇒ Object
Play the media.
-
#playback_rate ⇒ Integer or Float
Return media playbackRate property.
-
#playback_rate=(value) ⇒ Object
Set the media playbackRate property.
-
#preload ⇒ Object
Return media preload property.
-
#ready_state ⇒ Integer
Return media readyState property.
-
#seeking? ⇒ Boolean
Return media seeking property.
-
#src ⇒ String
Return media src property.
-
#unmute ⇒ Object
Unmute the media's audio.
-
#volume ⇒ Float
Return media volume property.
-
#volume=(value) ⇒ Object
Set the media volume property.
-
#wait_until_ready_state_is(value, seconds = nil, post_exception = true) ⇒ Object
Wait until the media object's readyState value equals the specified value, or until the specified wait time has expired.
Methods inherited from UIElement
#aria_autocomplete, #aria_busy?, #aria_checked?, #aria_colcount, #aria_controls, #aria_describedby, #aria_disabled?, #aria_expanded?, #aria_haspopup?, #aria_hidden?, #aria_invalid?, #aria_keyshortcuts, #aria_label, #aria_labelledby, #aria_live, #aria_modal?, #aria_multiline?, #aria_multiselectable?, #aria_orientation, #aria_pressed?, #aria_readonly?, #aria_required?, #aria_roledescription, #aria_rowcount, #aria_selected?, #aria_sort, #aria_valuemax, #aria_valuemin, #aria_valuenow, #aria_valuetext, #clear_alt_locator, #click, #click_at, #content_editable?, #count, #crossorigin, #disabled?, #displayed?, #double_click, #drag_and_drop, #drag_by, #enabled?, #exists?, #find_element, #focused?, #get_attribute, #get_locator, #get_locator_type, #get_name, #get_native_attribute, #get_object_type, #get_value, #height, #hidden?, #highlight, #hover, #hover_at, #initialize, #inspect, #obscured?, #required?, #right_click, #role, #scroll_to, #send_keys, #set, #set_alt_locator, #set_locator_type, #style, #tabindex, #title, #unhighlight, #verify_value, #visible?, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible, #width, #x, #y
Constructor Details
This class inherits a constructor from TestCentricity::UIElement
Instance Method Details
#autoplay? ⇒ Boolean
Return media autoplay property
9 10 11 12 13 14 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 9 def autoplay? obj, = find_element(visible = :all) object_not_found_exception(obj, @type) state = obj.native.attribute('autoplay') state.boolean? ? state : state == 'true' end |
#controls? ⇒ Boolean
Return media controls property
35 36 37 38 39 40 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 35 def controls? obj, = find_element(visible = :all) object_not_found_exception(obj, @type) state = obj.native.attribute('controls') state.boolean? ? state : state == 'true' end |
#current_time ⇒ Float
Return media currentTime property
125 126 127 128 129 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 125 def current_time obj, = find_element(visible = :all) object_not_found_exception(obj, @type) obj.native.attribute('currentTime').to_f.round(2) end |
#current_time=(value) ⇒ Object
Set the media currentTime property
222 223 224 225 226 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 222 def current_time=(value) obj, = find_element(visible = :all) object_not_found_exception(obj, @type) page.execute_script('arguments[0].currentTime = arguments[1]', obj, value) end |
#default_muted? ⇒ Boolean
Return media defaultMuted property
74 75 76 77 78 79 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 74 def default_muted? obj, = find_element(visible = :all) object_not_found_exception(obj, @type) mute_state = obj.native.attribute('defaultMuted') mute_state.boolean? ? mute_state : mute_state == 'true' end |
#default_playback_rate ⇒ Integer or Float
Return media defaultPlaybackRate property
137 138 139 140 141 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 137 def default_playback_rate obj, = find_element(visible = :all) object_not_found_exception(obj, @type) obj.native.attribute('defaultPlaybackRate').to_f end |
#duration ⇒ Float
Return media duration property
149 150 151 152 153 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 149 def duration obj, = find_element(visible = :all) object_not_found_exception(obj, @type) obj.native.attribute('duration').to_f.round(2) end |
#ended? ⇒ Boolean
Return media ended property
22 23 24 25 26 27 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 22 def ended? obj, = find_element(visible = :all) object_not_found_exception(obj, @type) state = obj.native.attribute('ended') state.boolean? ? state : state == 'true' end |
#loop? ⇒ Boolean
Return media loop property
48 49 50 51 52 53 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 48 def loop? obj, = find_element(visible = :all) object_not_found_exception(obj, @type) loop_state = obj.native.attribute('loop') loop_state.boolean? ? loop_state : loop_state == 'true' end |
#mute ⇒ Object
Mute the media's audio
255 256 257 258 259 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 255 def mute obj, = find_element(visible = :all) object_not_found_exception(obj, @type) page.execute_script('arguments[0].muted = true;', obj) end |
#muted? ⇒ Boolean
Return media muted property
61 62 63 64 65 66 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 61 def muted? obj, = find_element(visible = :all) object_not_found_exception(obj, @type) mute_state = obj.native.attribute('muted') mute_state.boolean? ? mute_state : mute_state == 'true' end |
#pause ⇒ Object
Pause the media
244 245 246 247 248 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 244 def pause obj, = find_element(visible = :all) object_not_found_exception(obj, @type) page.execute_script('arguments[0].pause()', obj) end |
#paused? ⇒ Boolean
Return media paused property
87 88 89 90 91 92 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 87 def paused? obj, = find_element(visible = :all) object_not_found_exception(obj, @type) paused_state = obj.native.attribute('paused') paused_state.boolean? ? paused_state : paused_state == 'true' end |
#play ⇒ Object
Play the media
233 234 235 236 237 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 233 def play obj, = find_element(visible = :all) object_not_found_exception(obj, @type) page.execute_script('arguments[0].play()', obj) end |
#playback_rate ⇒ Integer or Float
Return media playbackRate property
161 162 163 164 165 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 161 def playback_rate obj, = find_element(visible = :all) object_not_found_exception(obj, @type) obj.native.attribute('playbackRate').to_f end |
#playback_rate=(value) ⇒ Object
Set the media playbackRate property
278 279 280 281 282 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 278 def playback_rate=(value) obj, = find_element(visible = :all) object_not_found_exception(obj, @type) page.execute_script('arguments[0].playbackRate = arguments[1]', obj, value) end |
#preload ⇒ Object
Return media preload property
302 303 304 305 306 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 302 def preload obj, = find_element object_not_found_exception(obj, @type) obj.native.attribute('preload') end |
#ready_state ⇒ Integer
Return media readyState property
178 179 180 181 182 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 178 def ready_state obj, = find_element(visible = :all) object_not_found_exception(obj, @type) page.execute_script('return arguments[0].readyState', obj) end |
#seeking? ⇒ Boolean
Return media seeking property
100 101 102 103 104 105 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 100 def seeking? obj, = find_element(visible = :all) object_not_found_exception(obj, @type) state = obj.native.attribute('seeking') state.boolean? ? state : state == 'true' end |
#src ⇒ String
Return media src property
113 114 115 116 117 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 113 def src obj, = find_element(visible = :all) object_not_found_exception(obj, @type) obj.native.attribute('src') end |
#unmute ⇒ Object
Unmute the media's audio
266 267 268 269 270 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 266 def unmute obj, = find_element(visible = :all) object_not_found_exception(obj, @type) page.execute_script('arguments[0].muted = false;', obj) end |
#volume ⇒ Float
Return media volume property
210 211 212 213 214 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 210 def volume obj, = find_element(visible = :all) object_not_found_exception(obj, @type) obj.native.attribute('volume').to_f end |
#volume=(value) ⇒ Object
Set the media volume property
290 291 292 293 294 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 290 def volume=(value) obj, = find_element(visible = :all) object_not_found_exception(obj, @type) page.execute_script('arguments[0].volume = arguments[1]', obj, value) end |
#wait_until_ready_state_is(value, seconds = nil, post_exception = true) ⇒ Object
Wait until the media object's readyState value equals the specified value, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Capybara.default_max_wait_time.
192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/testcentricity_web/web_elements/media.rb', line 192 def wait_until_ready_state_is(value, seconds = nil, post_exception = true) timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds wait = Selenium::WebDriver::Wait.new(timeout: timeout) wait.until { ready_state == value } rescue StandardError if post_exception raise "Ready state of media #{} failed to equal '#{value}' after #{timeout} seconds" unless get_value == value else ready_state == value end end |