玩&使用Selenium暂停视频 [英] Play & pause video using Selenium

查看:74
本文介绍了玩&使用Selenium暂停视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是使用硒自动播放/暂停网页上显示的YouTube视频.

My aim is to automate play/pause YouTube video present on the web page using selenium.

如何使用Selenium的Java代码播放/暂停YouTube视频?

How to play/pause YouTube video with Java code for Selenium?

推荐答案

我是一个很酷的人,所以我将在这里发布一些代码.

I'm a cool guy so i'll post some code here.

driver.get("video link"); // open your browser at youtube video.

WebElement video = driver.findElement(By.id("id video")); // use the id of the video to find it

video.click(); // play the video

// implicite wait
//code .....

video.click(); // pause de video

在实践中,您将添加一些条件,例如,如果视频的长度栏已完成,请另外再添加一个视频.

With pracctice you'll add some conditions like if the video's lenghtbar is finish get another video else blablabla .

这篇关于玩&使用Selenium暂停视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆