gpt4 book ai didi

c# - C#Selenium如何单击嵌入的youtube视频的播放按钮

转载 作者:行者123 更新时间:2023-12-03 05:21:44 25 4
gpt4 key购买 nike

https://pinstopins.blogspot.com/2020/04/sayac-canl.html

我的代码:

driver1.FindElement(By.XPath("//button[@class='ytp-large-play-button ytp-button'")).Click();

博客作者youtube视频播放单击什么代码?

谢谢!

最佳答案

我检查了您发布的平台。为了点击播放按钮,您必须输入iframe:

enter image description here

为此,请检查以下示例:

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的官方网站(这是浏览器操作部分)。

关于c# - C#Selenium如何单击嵌入的youtube视频的播放按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61563895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com