How to click on the play button of a youtube video embedded within smtebook through selenium and python

how to play and pause video in selenium
play youtube video using selenium python
selenium youtube python
scraping using selenium python
download video selenium python
youtube scraping using selenium
selenium click button
selenium python tutorial

I want click the youtube play in

my code is :

element = browser.find_element_by_xpath("//button[@class='ytp-large-play-button ytp-button']")

but can not find element

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//button[@class='ytp-large-play-button ytp-button']"}
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.37.543627 (63642262d9fb93fb4ab52398be4286d844092a5e),platform=Windows NT 10.0.17134 x86_64)

Anyone have some idea how to deal with it ?

Thank you!

To be able to handle embedded video player you need to switch to appropriate iframe and wait for button to appeared in DOM:

from import By
from import WebDriverWait
from import expected_conditions as EC

browser.switch_to.frame(browser.find_element_by_xpath('//iframe[starts-with(@src, "")]'))
WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, '//button[@aria-label="Play"]'))).click()

How to search and open a Youtube video with selenium?, from import expected_conditions as EC driver = webdriver. to url with video being appended to search_query video = 'dragon city best hack + str(video)) # play the video [1]/ytd-video-renderer[2]/div[1]/div​/div[1]/div/h3/a').click() time.sleep(20) python youtube selenium. Autoplay When autoplay is enabled, a suggested video will automatically play next. Up next How to write Script in Selenium Webdriver (First Testcase in Selenium) - Duration: 18:39.

Always switch to frame using name or some locator :

required_frame = driver.find_element_by_xpath("//iframe[contains(@src,'')]")

And then, below code works,

element = driver.find_element_by_xpath("//button[@aria-label='Play']")

YouTubeControl: youtubecobtrol, Selenium Webdriver allows users to interact with iframes on the page but you have to Duration: 7:32 Posted: Jan 13, 2018 Autoplay When autoplay is enabled, a suggested video will automatically play next. Up next Handle Dynamic Radio Button and Check Box in Selenium Webdriver - Duration: 16:47.

If the only aim is to play the video, you can just refresh the page by using driver.refresh()

for e.g below works for me.

from selenium import webdriver
import time

def watchvideo():
driver = webdriver.Chrome(executable_path="/Users/kamlesh/chromedriver")

Selenium Webdriver - iFrames, Click here to visit our frequently asked questions about HTML5 video. Frame is a web page Duration: 5:30 Posted: Jul 28, 2018 Advanced Python Programming Tutorials! Check out my latest video on Browser Automation with Selenium. We'll understand what Selenium is, how to install the webdriver and the various functions

Selenium with Java 43 - How to handle Frame, Learn how to click a radio button using python selenium webdriver Click here to visit our Duration: 5:00 Posted: Jul 12, 2015 Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

Python Selenium Click Radio Button, Learn how to Click URL by Link Text in Python Selenium Webdriver.Duration: 5:11 Posted: Jul 9, 2015 you need selenium library if you have not selenium library installed go to command line "pip install selenium"

Python Selenium Webdriver Click by link text, how to check screen size of iphone 4 and iphone 5 programmatically in swift to click on the play button of a youtube video embedded within smtebook through  Locate the element where it hold the youtube video. Get the height and width of the element. Most of the time if there are no any video available the height and width should be differ from the height and width when you have a youtube video. So assert the height and width.

how to check screen size of iphone 4 and iphone 5 , element = driver.find_element_by_xpath("//button[@aria-label='Play']") browser​.switch_to.frame(browser.find_element_by_xpath('//iframe[starts-with(@ В соответствии с вашим вопросом, чтобы вызвать click() на кнопке воспроизведения youtube на​serverless-python-  to find the html element. To get the path, we can use chrome development tools (press F12). We take the pointer in devtools and select the html button we are interested in. The path will then be shown, as the example screenshot: After we have the html object, we use the click() method to make the final click.