【发布时间】:2017-07-25 06:22:29
【问题描述】:
我正在尝试在 youtube 上点击使用类来播放视频
在这个页面https://likesrock.com使用这个代码
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("https://likesrock.com")
element = driver.find_element_by_class_name("ytp-large-play-button ytp-button")
element.click()
但是编译器给了我这个错误
Traceback(最近一次调用最后一次): 文件“C:\Users\youssef\Desktop\python project\xpath.py”,第 25 行,在 element = driver.find_element_by_class_name("ytp-large-play-button ytp-button") 文件“C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py”,第 413 行,在 find_element_by_class_name 中 return self.find_element(by=By.CLASS_NAME, value=name) 文件“C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py”,第 752 行,在 find_element '价值':价值})['价值'] 执行中的文件“C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py”,第 236 行 self.error_handler.check_response(响应) 文件“C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py”,第 192 行,在 check_response 引发异常类(消息、屏幕、堆栈跟踪) NoSuchElementException:消息:无法找到元素:.ytp-large-play-button ytp-button
请帮忙
【问题讨论】:
-
见here。
标签: python python-2.7 selenium selenium-webdriver youtube