LoginSignup
2
2

More than 1 year has passed since last update.

[Python] Selenium タイムアウトエラー時にリトライ

Last updated at Posted at 2023-01-18

該当エラー

selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: 600.000

リトライ(再試行)ロジック

        retry_count = 3
        for retry_time in range(retry_count):
            try:
                # Selenium code that might raise TimeoutException
                # selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: 600.000
                
                selenium_execute() # <= selenium 処理を記述
                break
            except TimeoutException:
                print(f'Attempt {retry_time + 1} failed')
                if retry_time == (retry_count - 1):  # If the last retry
                    raise Exception('All retries failed')
                continue

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2