测试播放,停止播放 http://www.videojs.com/
示例:
package com.learningselenium.html5;
import static org.junit.Assert.*;
import org.junit.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class testHTML5VideoPlayer{
WebDriver driver = new FirefoxDriver();
@Before
public void setUp() throws Exception{
driver.get("http://www.videojs.com/");
}
@Test
public void testHTML5Video() throws Exception{
WebElement video = driver.findElement(By.id("home_fideo_html5_api"));
JavascriptExecutor jse = (JavascriptExecutor )driver;
String source = (String) jse.executeScript("return arguments[0].currentSrc;", video);
//获取视频的播放源
assertEquals("http://vjs.zencdn.net/v/oceans.webm", source);
//播放
jse.executeScript("return argument[0].play", video);
Thread.sleep(5000);
//暂停
jse.executeScript("argument[0].pause()", video);
}
@After
public void tearDown() throws Exception{
driver.quit();
}
}