问题
My aim is to automate play/pause YouTube video present on the web page using selenium.
How to play/pause YouTube video with Java code for Selenium?
回答1:
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 .
来源:https://stackoverflow.com/questions/16162291/play-pause-video-using-selenium