我收到以下错误:
回溯(最近一次调用(:文件"[已编辑]",第 69 行,在 wait.until(EC.element_to_be_clickable(By.ID("RptViewer_ctl09_ctl04_ctl00_ButtonLink"((( 类型错误:"str"对象不可调用
这是我认为导致问题的代码部分:
66 browser.find_element_by_id('RptViewer_ctl09_ctl04_ctl00_ButtonLink')
67 drp = browser.find_element_by_id('RptViewer_ctl09_ctl04_ctl00_ButtonLink')
68 wait = WebDriverWait(browser, 10)
69 wait.until(EC.element_to_be_clickable(By.ID('RptViewer_ctl09_ctl04_ctl00_ButtonLink')))
70 drp.click()
我认为导致问题的原因是"ID('RptViewer_ctl09_ctl04_ctl00_ButtonLink'("部分,但我不确定这是否属实,也不确定如何解决它。非常感谢任何指导。
谢谢!
将 WebDriverWait 与 expected_conditions 结合使用时,您必须将定位器括在元组中,如下所示:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "RptViewer_ctl09_ctl04_ctl00_ButtonLink")))
By.ID 是一个字符串。不可调用。预期条件采用元组形式的定位器(正如 quamrana 已经建议的那样(