【发布时间】: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