1 回答

TA貢獻1155條經(jīng)驗 獲得超0個贊
更新了提問者的失敗代碼示例,錯誤.click():
element = WebDriverWait(self.driver, 30).until( EC.element_to_be_clickable((By.XPATH, '//*[@id="tab-content-2"]/div/md-content/div[9]/a/span'))).click()
element = WebDriverWait(self.driver, 30).until( EC.element_to_be_clickable((By.ID, 'adminCreateConsultation'))).click()
我認為這里的問題與連接wait.until和.click()操作有關。嘗試像這樣拆分代碼:
# Wait for the element to exist
WebDriverWait(self.driver, 30).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="tab-content-2"]/div/md-content/div[9]/a/span')))
# then click it
driver.find_element_by_xpath("//*[@id="tab-content-2"]/div/md-content/div[9]/a/span").click()
# Wait for the element to exist
WebDriverWait(self.driver, 30).until(EC.element_to_be_clickable((By.ID, 'adminCreateConsultation')))
# then click it -- need to use Javascript click for this element
createConsultationButton = driver.find_element_by_id("adminCreateConsultation")
driver.execute_script("arguments[0].click();", createConsultationButton)
添加回答
舉報