@@ -200,6 +200,29 @@ def open(self, url):
200
200
):
201
201
time.sleep(0.5)
202
202
self.driver.get(url)
203
+ elif "Timed out receiving message from renderer" in e.msg:
204
+ page_load_timeout = None
205
+ if selenium4_or_newer:
206
+ page_load_timeout = self.driver.timeouts.page_load
207
+ else:
208
+ if hasattr(settings, "PAGE_LOAD_TIMEOUT"):
209
+ page_load_timeout = settings.PAGE_LOAD_TIMEOUT
210
+ else:
211
+ page_load_timeout = 120
212
+ logging.info(
213
+ "The page load timed out after %s seconds! Will retry..."
214
+ % page_load_timeout
215
+ )
216
+ try:
217
+ self.driver.get(url)
218
+ except Exception as e:
219
+ if "Timed out receiving message from renderer" in e.msg:
220
+ raise Exception(
221
+ "Retry of page load timed out after %s seconds!"
222
+ % page_load_timeout
223
+ )
224
+ else:
225
+ raise
203
226
elif (
204
227
"cannot determine loading status" in e.msg
205
228
or "unexpected command response" in e.msg
@@ -5475,6 +5498,12 @@ def get_beautiful_soup(self, source=None):
5475
5498
from bs4 import BeautifulSoup
5476
5499
5477
5500
if not source:
5501
+ try:
5502
+ self.wait_for_element_visible(
5503
+ "body", timeout=settings.MINI_TIMEOUT
5504
+ )
5505
+ except Exception:
5506
+ pass
5478
5507
source = self.get_page_source()
5479
5508
soup = BeautifulSoup(source, "html.parser")
5480
5509
return soup
@@ -6277,13 +6306,13 @@ def assert_title(self, title):
6277
6306
self.assertEqual(expected, actual, error % (expected, actual))
6278
6307
except Exception:
6279
6308
self.wait_for_ready_state_complete()
6280
- time.sleep(settings.MINI_TIMEOUT )
6309
+ time.sleep(2 )
6281
6310
actual = self.get_page_title().strip()
6282
6311
try:
6283
6312
self.assertEqual(expected, actual, error % (expected, actual))
6284
6313
except Exception:
6285
6314
self.wait_for_ready_state_complete()
6286
- time.sleep(settings.MINI_TIMEOUT )
6315
+ time.sleep(2 )
6287
6316
actual = self.get_page_title().strip()
6288
6317
self.assertEqual(expected, actual, error % (expected, actual))
6289
6318
if self.demo_mode and not self.recorder_mode:
@@ -11134,6 +11163,12 @@ def check_window(
11134
11163
self.check_window(name="wikipedia_page", level=3)
11135
11164
"""
11136
11165
self.wait_for_ready_state_complete()
11166
+ try:
11167
+ self.wait_for_element_visible(
11168
+ "body", timeout=settings.MINI_TIMEOUT
11169
+ )
11170
+ except Exception:
11171
+ pass
11137
11172
if level == "0":
11138
11173
level = 0
11139
11174
if level == "1":
@@ -12807,6 +12842,12 @@ def setUp(self, masterqa_mode=False):
12807
12842
# Configure the test time limit (if used).
12808
12843
self.set_time_limit(self.time_limit)
12809
12844
12845
+ # Configure the page load timeout
12846
+ if hasattr(settings, "PAGE_LOAD_TIMEOUT"):
12847
+ self.driver.set_page_load_timeout(settings.PAGE_LOAD_TIMEOUT)
12848
+ else:
12849
+ self.driver.set_page_load_timeout(120) # Selenium uses 300
12850
+
12810
12851
# Set the start time for the test (in ms).
12811
12852
# Although the pytest clock starts before setUp() begins,
12812
12853
# the time-limit clock starts at the end of the setUp() method.
0 commit comments