Testing 如何玩&;使用Selenium暂停视频?

Testing 如何玩&;使用Selenium暂停视频?,testing,selenium,automation,Testing,Selenium,Automation,有人能帮助我如何使用Selenium自动播放/暂停网页上的视频吗 提前感谢…这取决于处理视频的浏览器和播放器。您很可能需要使用JavaScript执行器 昨晚我和一个朋友讨论了这个问题,他在html5demos.com的演示视频中使用了Webdriver的Python变体,给出了以下示例: driver = webdriver.Firefox() driver.get("http://html5demos.com/video") driver.execute_script('document.g

有人能帮助我如何使用Selenium自动播放/暂停网页上的视频吗


提前感谢…

这取决于处理视频的浏览器和播放器。您很可能需要使用JavaScript执行器

昨晚我和一个朋友讨论了这个问题,他在html5demos.com的演示视频中使用了Webdriver的Python变体,给出了以下示例:

driver = webdriver.Firefox()
driver.get("http://html5demos.com/video")
driver.execute_script('document.getElementsByTagName("video")[0].play()')
您还可以在使用“播放”的位置“暂停”

这里有一个更大的问题:你到底想验证什么?简单的演奏和暂停不会带来任何错误?确保您知道要验证的内容,并确保将视频测试自动化是有意义的,而不是将特定用例留给手动测试。(尽管您可以使用上面的脚本来实现这一点!)


**编辑:签出(不是我的),它公开了一个“暂停”属性。现在,您至少可以验证视频加载、启动和停止。我仍然怀疑这种测试的使用,但至少这是一个开始。

使用FlashObjectwebDriver

现在什么是FlashObjectWebDriver

FlashObjectWebDriver是Webdriver库下的一个接口。 FlashObjectWebDriver有一个名为callFlashObject的方法 callFlashObject方法可以使用参数ie过度加载。 callFlashObject(“播放”):用于播放Flash callFlashObject(“暂停”):用于暂停闪存 callFlashObject(“先前”):用于播放先前的Flash视频 callFlashObject(“下一个”):用于播放下一个Flash视频 callFlashObject(“SetVariable”,“/:Message):用于显示消息。 实施:

FlashObjectWebDriver flashApp = new FlashObjectWebDriver(driver, "myFlashMovie");       
    // Pass the URL of video        
    driver.get("http://demo.guru99.com/flash-testing.html");            
    Thread.sleep(5000);     
    flashApp.callFlashObject("Play");           
    Thread.sleep(5000);     
    flashApp.callFlashObject("StopPlay");           
    Thread.sleep(5000);     
    flashApp.callFlashObject("SetVariable","/:message","Flash testing using selenium Webdriver");
    System.out.println(flashApp.callFlashObject("GetVariable","/:message"));

你是一个黄金神——这只是用一行代码解决了三个小时的修补所不能解决的问题。如果浏览器阻止自动播放视频,这就不起作用。在播放视频之前,我必须先单击页面上的某些元素,以模拟用户交互,从而允许播放视频。你使用了哪种编程语言?