'How do I fast forward (scrub) through a video using selenium python?

So far, I was able to use the below to play the video. but I want to scrub the video to the end in order to end the season and move on the next page. how do I do that? below is what i have written so far. once you get to the video will play but is there a way to end the video quickly?

import pyautogui as pg
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.wait import WebDriverWait
import selenium.webdriver.support.expected_conditions as ec



driver = webdriver.Chrome(ChromeDriverManager().install())

driver.get("______________")
wait = WebDriverWait(driver, 5, 1)
driver.find_element_by_id("Username").send_keys("[email protected]")
driver.find_element_by_css_selector("input[id='Password']").send_keys("0i0i0i0i")

loginB = driver.find_element_by_id("login-button").click()

coursex = wait.until(ec.visibility_of_element_located((By.XPATH,"//p[text()='xAPI Testing - PCI DSS']")))
coursex.click()

coursex2 = wait.until(ec.visibility_of_element_located((By.XPATH,"//a[text()='xAPI Testing - PCI DSS']")))
coursex2.click()

childwindow = driver.window_handles[0]
driver.switch_to.window(childwindow)
time.sleep(9)

wait = WebDriverWait(driver, 5, 1)

wait.until(ec.frame_to_be_available_and_switch_to_it("ext-gen24"))
wait.until(ec.frame_to_be_available_and_switch_to_it("dispatch_content_frame"))
wait.until(ec.frame_to_be_available_and_switch_to_it("contentRelay"))
wait.until(ec.frame_to_be_available_and_switch_to_it("ScormContent"))

contin = wait.until(ec.visibility_of_element_located((By.ID, "welcome-continue")))
driver.execute_script("arguments[0].click();", contin)

childwindow2 = driver.window_handles[0]
driver.switch_to.window(childwindow2)
time.sleep(4)

wait.until(ec.frame_to_be_available_and_switch_to_it("ext-gen24"))
wait.until(ec.frame_to_be_available_and_switch_to_it("dispatch_content_frame"))
wait.until(ec.frame_to_be_available_and_switch_to_it("contentRelay"))
wait.until(ec.frame_to_be_available_and_switch_to_it("ScormContent"))

contin2 = driver.find_element_by_id("affirmationButton").click()

childwindow3 = driver.window_handles[0]
driver.switch_to.window(childwindow3)

wait.until(ec.frame_to_be_available_and_switch_to_it("ext-gen24"))
wait.until(ec.frame_to_be_available_and_switch_to_it("dispatch_content_frame"))
wait.until(ec.frame_to_be_available_and_switch_to_it("contentRelay"))
wait.until(ec.frame_to_be_available_and_switch_to_it("ScormContent"))

video = driver.find_element_by_id("mainVideo_html5_api")
driver.execute_script("arguments[0].click();", video)```


Solution 1:[1]

Just use pyautogui to press the arrow keys.

import pyautogui
import time 

while True:
     pyautogui.press("right")
     time.sleep(enter how many seconds in between each press.)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mojochicken