这个怎么样?
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
try:
addButton=WebDriverWait(browser,5).until(EC.element_to_be_clickable((By.CLASS_NAME,"addToCartLabel_YZaVX")))
addButton.click()
except :
print("Couldn't find the button, doing some other action here)
#do other stuff here...
pass