所以我想抓住Webdriver异常,不希望它的回溯污染我的日志。下面是代码不能捕捉到异常
from selenium.common.exceptions import TimeoutException, WebDriverException
try:
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, '.loading')))
except TimeoutException:
log.msg("Seneium Timeout: {}".format(response.url))
except WebDriverException as e:
log.msg("Selenium Exception: {0} Message: {1}".format("my message", str(e)))
finally:
driver.quit()
尚未到位,我还是让这些:
<full traceback here>
selenium.common.exceptions.WebDriverException: Message: Can not connect to GhostDriver
我在做什么错?
你确定在'try'块中发生异常吗? –