我試圖單擊使用類點擊YouTube上使用此代碼點擊YouTube的按鈕硒蟒蛇檢查我的代碼
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()
但compilor給我這個erorr vadio
回溯(最近一次調用最後一次): 文件「C:\ Users \ youssef \ Desktop \ python project \ xpath.py」,第25行,在 element = driver.find_ele ment_by_class_name(「ytp-large-play-button ytp-button」) find_element_by_class_name中的第413行文件「C:\ Python27 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py」 return self.find_element (by = By.CLASS_NAME,value = name) 文件「C:\ Python27 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py」,第752行,在find_element中 'value':value})[ 'value'] 文件「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 引發exception_class(消息,屏幕,堆棧跟蹤) NoSuchElementException:消息:Unable to loca熱電元件:.ytp大型播放按鈕YTP-按鈕
請
參見[這裏] (http://stackoverflow.com/q/10658907/7023590)。 – MarianD