【问题标题】:How do I fast forward (scrub) through a video using selenium python?如何使用 selenium python 快进(擦洗)视频?
【发布时间】:2022-02-26 02:27:48
【问题描述】:

到目前为止,我可以使用下面的视频播放视频。但我想将视频拖到最后,以便结束本赛季并进入下一页。我怎么做?以下是我到目前为止所写的。一旦你到达视频就会播放,但有没有办法快速结束视频?

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("bn@gmail.vom")
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)```

【问题讨论】:

  • 用相关的 HTML 更新问题

标签: python html selenium automation pycharm


【解决方案1】:

只需使用 pyautogui 按箭头键即可。

import pyautogui
import time 

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

【讨论】:

  • 没有右箭头键。它只是播放器上的一个播放和暂停按钮。方向键对玩家没有影响
猜你喜欢
  • 2019-06-23
  • 1970-01-01
  • 2019-04-05
  • 1970-01-01
  • 2014-08-18
  • 1970-01-01
  • 1970-01-01
  • 2012-06-20
  • 1970-01-01
相关资源
最近更新 更多