概要 Seleniumでページの読み込みが終わらない現象が時々発生し、エラーとなってテスト実行が不安定となるため、リトライを試してみる。 ページの読み込み最大待ち時間の指定する とりあえず、読み込みを待つ最大の時間をセットして、 ページ読み込みが終わらない場合は終了させる。 from selenium import webdriver driver = webdriver.Chrome("D:\chromedriver") driver.set_page_load_timeout(10) # 10秒 try: driver.get("https://google.co.jp/") print("The page was loaded in time!") except: print("time out!") #!/usr/bin/python import unittest, time