【问题标题】:Python Selenium TimeoutExceptionPython Selenium 超时异常
【发布时间】:2021-02-25 15:00:37
【问题描述】:

是否可以扩展 Selenium 的默认 TimeoutException?

我的脚本在页面加载超过 300 秒时崩溃。我的脚本在我的后端触发了一个 php 脚本。如果 php 脚本运行时间少于 300 秒,则一切正常,但在脚本运行时间较长时,selenium 会抛出 TimeoueException 错误。

TimeoutException:消息:超时:从渲染器接收消息超时:300.000

有没有办法告诉 Selenium 等到脚本运行完毕?

我已经尝试过 expected_conditions,但没有帮助。

【问题讨论】:

  • 您可以使用 chrome_driver.set_page_load_timeout(seconds) 设置页面加载超时...在 chromedriver 中默认为 30 秒...

标签: selenium selenium-webdriver selenium-chromedriver python-3.9


【解决方案1】:

嘿,也许这可以解决你的问题

from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.ID, 'someid')))

它会等到提到的按钮是可点击的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-01
    • 1970-01-01
    • 2021-03-31
    • 2017-04-19
    • 1970-01-01
    • 2016-09-16
    • 1970-01-01
    相关资源
    最近更新 更多