我用过
quotes = browser.find_element_by_id('CQ')
quotes.click()
但它回来了
Unable to locate element: {"method":"id","selector":"CQ"}
也许我的函数/参数不对。
答案 0 :(得分:1)
由于页面加载的性质,有时需要Webdriver等待。尝试等待,直到首先显示/启用该元素,然后再单击它。用于WebDriver的Python Selenium文档等待:http://selenium-python.readthedocs.io/waits.html。
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
element = wait.until(EC.visibility_of_element_located((By.ID, 'someid')))