zoukankan      html  css  js  c++  java
  • [Selenium] WebDriver 操作 HTML5 中的 video

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

      }

    }

  • 相关阅读:
    消息机制
    窗口!窗口!- Windows程序设计(SDK)003
    内联函数的作用
    结构体变量用 . 结构体指针用-> 的原因
    &a和a的区别
    分布电容
    介电常数
    天线
    封装的思想
    关于中断标志位
  • 原文地址:https://www.cnblogs.com/feifeidxl/p/4554560.html
Copyright © 2011-2022 走看看