2

I am using Webdriver in Ruby and I want to verify the seek and volume slider controls of the html5 dash-cenc player inside an iFrame.

The idea is to just check if the player accepts the command to seek "x" time ahead or to go to the beginning of the playback and then seek to half the seek progress bar. The problem is that manually testing the player, the "arrow keys" didn't work, so the only way to seek the playback, is to click the place you want in the seekbar.

Here is the piece of html I want to verify when the player starts the playback:

<div id="progressbar" data-value="0" class="ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all"><div class="ui-slider-range ui-widget-header ui-corner-all ui-slider-range-min" style="width: 61.436170212766%;"></div><span class="ui-slider-handle ui-state-default ui-corner-all" tabindex="0" style="left: 61.436170212766%;"><div class="tooltip-container" style="display: none;"><div id="time-tooltip">0:03:50</div><div class="triangle-down"></div></div></span></div>

I tried a couple of examples with no luck, this is a part of the code i made, the test case runs and the event "click" in the "Toggle-play" element works just fine:

    reg = @driver.find_element(:id, "fancybox-frame")
    @driver.switch_to.frame reg
    @driver.find_element(:id, "toggle-play").click

I attached a screenshot of the media controls and the "inspect element" part of the Google Chrome browser (the player only works with Google Chrome, not Firefox)

2 Answers 2

1

I've found the answer and tried this commands for the player:

@driver.execute_script("document.getElementById('dashplayer').load();")
@driver.execute_script("document.getElementById("dashplayer").pause();")
@driver.execute_script("document.getElementById('dashplayer').paused;")
@driver.execute_script("document.getElementById("dashplayer").play();")
@driver.execute_script("document.getElementById('dashplayer').volume;")
@driver.execute_script("document.getElementById('dashplayer').volume=0.5;")
0

Personally I believe that the best approach is to use the Java Script API of the player. Find the documentation and execute the commands via calling the JavaScript methods for the operations. Code to execute JavaScript in Ruby Driver:

# execute arbitrary javascript
puts driver.execute_script("return window.location.pathname")
# pass elements between Ruby and JavaScript
element = driver.execute_script("return document.body")
driver.execute_script("return arguments[0].tagName", element) #=> "BODY"
2
  • Thanks! but I don't understand how to add that code into my test case, for example, to make the player pause or play the content
    – Lea2501
    Aug 20, 2015 at 13:51
  • I added the following code with no sucess: @driver.execute_script("var vid = document.getElementById('dashplayer')") @driver.execute_script("return vid.duration") @driver.execute_script("return vid.currentTime") Its giving me a "vid is not defined" error
    – Lea2501
    Aug 20, 2015 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.