c# Selenium 如何点击嵌入的 youtube 视频的播放按钮
c# Selenium How to click on the play button of a youtube video embed
https://pinstopins.blogspot.com/2020/04/sayac-canl.html
我的代码:
driver1.FindElement(By.XPath("//button[@class='ytp-large-play-button ytp-button'")).Click();
博主youtube视频播放点击代码是什么?
谢谢!
我查看了你发布的平台。为了点击播放按钮,您必须进入 iframe:
为此请检查以下示例:
self.driver1 = webdriver.Firefox()
# Locate the iframe using the tag attribute.
driver1.SwitchTo.Frame(driver.FindElement(By.TagName("iframe"))
# After locating and entering into the iframe you now have access to the given video and you can click on that.
driver1.FindElement(By.XPath("//button[@class='ytp-large-play-button ytp-button'")).Click();
# After clicking on the button, I guess you don't need it anymore so you have to out of the iframe into the default content. So, you execute the following line.
driver.switchTo().defaultContent();
如果您需要更多详细信息,可以访问 Selenium 的官方网站(这是浏览器操作部分)。
https://pinstopins.blogspot.com/2020/04/sayac-canl.html
我的代码:
driver1.FindElement(By.XPath("//button[@class='ytp-large-play-button ytp-button'")).Click();
博主youtube视频播放点击代码是什么?
谢谢!
我查看了你发布的平台。为了点击播放按钮,您必须进入 iframe:
为此请检查以下示例:
self.driver1 = webdriver.Firefox()
# Locate the iframe using the tag attribute.
driver1.SwitchTo.Frame(driver.FindElement(By.TagName("iframe"))
# After locating and entering into the iframe you now have access to the given video and you can click on that.
driver1.FindElement(By.XPath("//button[@class='ytp-large-play-button ytp-button'")).Click();
# After clicking on the button, I guess you don't need it anymore so you have to out of the iframe into the default content. So, you execute the following line.
driver.switchTo().defaultContent();
如果您需要更多详细信息,可以访问 Selenium 的官方网站(这是浏览器操作部分)。