我试图检查屏幕上是否启用了按钮。我遇到的问题是" element_to_be_clickable"功能似乎没有发现该按钮是可点击的。
我的代码如下:
#check if the button is clickable
try:
WebDriverWait(self.driver, 2).until(EC.element_to_be_clickable(By.ID(button_id)))
button_status_screen = True
except Exception as e:
button_status_screen = False
# assert button enabled status on screen == expected status
button_status_screen = str(button_status_screen).strip()
Myresult = False #compare the expected result to the actual result
if button_status_excel == button_status_screen:
Myresult = True
assert Myresult == True, "Button was not enabled or disabled as expected."
当按钮启用时,尝试仍然会转到异常并将" button_status_screen设置为false(我希望将其设置为true并跳过异常)。
有谁知道可能导致问题的原因?