I would like to jump to a specific time while playing a video. While I have manage to achieve similar objective from YouTube website (see thread here), the same approach fail to work properly at a different website. As much I would like to share the website link, but due to confidential concern, Im unable to disclose it here.
The embedded video in this website have frame with the ID player
. And I know the following line is working without any error.
video = WebDriverWait(self.browser, 15).until(EC.visibility_of_element_located((By.ID, "player")))
Since, the iframe does not have a TagName
, I instead replace the getElementsByTagName
into getElementById
. However, the compiler return an error
Message: javascript error: Cannot read property 'currentTime' of undefined
The full code is as below
video = WebDriverWait(self.browser, 15).until(EC.visibility_of_element_located((By.ID, "player"))) # The line work perfectly
print('Fast forward')
player_status = self.browser.execute_script("document.getElementById('player')[0].currentTime += 80;") # The compiler return an error at this line.
print('Get Current time')
time_video = self.browser.execute_script("return document.getElementById('player')[0].currentTime;")
I appreciate for any hint or help.
Thanks in advance.