thoughtbot/capybara-webkit — Issue #229: Some HTML Element Properties are undefined when accessed via the attribute hash (esp. Video)
Author: jrreed
Created: 2011-12-16 20:01:22+00:00
State: open

I've noticed that not all properties are defined for HTML elements when you try to access them via the attribute hash. In particular, trying to access "paused" and "volume" properties for the HTML Video element returns the empty string. I think that this may be applicable to properties whose values are derived as opposed to explicitly set, but I'm not sure.

This seems inconsistent with the underlying driver because I can get the value of the property by executing javascript to retrieve it. Using the Capybara #evaluate_script(...) method.

I think this might be a bug because this isn't an issue if you drive the tests with the Selenium-Webdriver.

Here's a sample spec for a page that has a video element and play button. The video should start playing when you click the play button:

describe "Video Playback Test", :js => true do

before(:each) do
end

it "should start playing when you click the play button" do
# Try running the tests with both selenium and webkit
# Capybara.current_driver = :selenium
Capybara.current_driver = :selenium

visit "/videos/1"

# Start the video
find("#playButton").click

# Make sure that the video is playing
video = find("#videoElement")

# This test will succeed for both Selenium-Webdriver and Capybara-Webkit
get_paused = "$('#videoElement')[0].paused;"
is_paused = page.evaluate_script(get_paused)
is_paused.should eq(true)

# This test will fail for Capybara-Webkit and pass for Selenium-Webdriver
video[:paused].should eq("true")
end