首页 > Web开发 > 详细

WebDriver 操作 HTML5 中的 video

时间:2015-06-05 15:13:24      阅读:349      评论:0      收藏:0      [点我收藏+]

测试播放,停止播放 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();

  }

}

WebDriver 操作 HTML5 中的 video

原文:http://www.cnblogs.com/feifeidxl/p/4554560.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!