1 回答
TA贡献1155条经验 获得超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)
添加回答
举报