Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jumping a certain amount of time in html5 video using Selenium

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.

like image 971
Moondra Avatar asked Sep 05 '25 18:09

Moondra


1 Answers

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

document.getElementsByTagName("video")[0].currentTime += 30;
like image 189
alecxe Avatar answered Sep 08 '25 08:09

alecxe