Answer the question
In order to leave comments, you need to log in
How to play video in Cross Origin Iframe Selenium Python?
There is a script for checking the video
A link to the site page is passed, the video should start in it, but the video in the Iframe from another site, added --disable-web-security and --user-data-dir, still does not work, although the user sees. Selenium doesn't see running iframe code :(
Link - https://xn--h1agd3a1be.net/titles/1137/chto,-esli
Chrome - 94.0.4606.81
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
def start_video(url):
chrome_options = Options()
chrome_options.add_argument("--user-data-dir=C:/Users/DANA/AppData/Local/Google/Chrome/User Data/Profile 2")
chrome_options.add_argument("--disable-site-isolation-trials")
chrome_options.add_argument("--disable-web-security")
driver = webdriver.Chrome(
chrome_options = chrome_options,
executable_path = "C:/Users/DANA/Desktop/OpenServer/domains/localhost/python-films-bots/python/chromedriver/chromedriver.exe"
)
#driver.maximize_window()
try:
driver.get(url = url)
time.sleep(2)
#open video page
driver.find_element_by_class_name("play-button").click()
driver.implicitly_wait(5)
time.sleep(5)
#play player
driver.execute_script('document.getElementsByTagName("video")[0].play')
finally:
driver.close()
driver.quit()
Answer the question
In order to leave comments, you need to log in
Selenium doesn't see running iframe code :(
iframe = driver.find_element_by_xpath("//iframe")
driver.switch_to.frame(iframe)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question