目前我在 for 循环中使用多个异常。但是,它们仍然抛出异常错误,我不确定为什么它们没有被处理。
这是我的代码:
for x in range (15):
actions.click_and_hold(element1).move_to_element(element2).release().perform()
try:
WebDriverWait(driver, 5).until(
EC.visibility_of_element_located((elementLocator))
)
return True
except (StaleElementReferenceException, TimeoutException):
break
这是抛出的错误:
StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: headless chrome=67.0.3396.30)
(Driver info: chromedriver=2.36.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8),platform=Mac OS X 10.13.4 x86_64)