Jumping a certain amount of time in html5 video using Selenium

强颜欢笑 提交于 2021-02-07 04:29:15

问题


I'm testing out Selenium's html5 video automation methods, I can't find one to jump a certain amount of time for current location in the video.

driver = webdriver.Firefox()
driver.get("https://www.youtube.com/watch?v=v_I4zqC7GN8")
driver.execute_script('document.getElementsByTagName("video")[0].currentTime=30

allows me to jump to the 30-second time mark.

However, I want to jump 30-seconds from my current time position.

Most tutorials are in java, with some getting really deep into java code -- I'm unfamiliar with Java.


回答1:


You just need to add 30 to the current currentTime value:

document.getElementsByTagName("video")[0].currentTime += 30;


来源:https://stackoverflow.com/questions/45557026/jumping-a-certain-amount-of-time-in-html5-video-using-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!