[FIX] tests: increase browser_js ready code timeout
Before starting a JS test/tour the _wait_ready method evaluates if the test is ready with a timeout of 10 sec. From times to times, it happens that the page is not ready after this timeout but the problem is hidden. In order to help fixing that kind of issue, the timeout is increased to 60 sec and a warning is logged to emphasis the fact that an issue exists. Also some unused imports are removed with this commit
This commit is contained in:
committed by
Christophe Simonis
parent
614884928e
commit
ecaa04ec82
+10
-9
@@ -6,8 +6,6 @@ helpers and classes to write tests.
|
||||
"""
|
||||
import base64
|
||||
import collections
|
||||
import errno
|
||||
import glob
|
||||
import importlib
|
||||
import itertools
|
||||
import json
|
||||
@@ -16,19 +14,15 @@ import operator
|
||||
import os
|
||||
import re
|
||||
import requests
|
||||
import select
|
||||
import shutil
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
import unittest
|
||||
import werkzeug.urls
|
||||
from contextlib import contextmanager
|
||||
from datetime import datetime, timedelta, date
|
||||
from pprint import pformat
|
||||
from datetime import datetime, date
|
||||
|
||||
from decorator import decorator
|
||||
from lxml import etree, html
|
||||
@@ -538,13 +532,15 @@ class ChromeBrowser():
|
||||
params = {'name': name, 'value': value, 'path': path, 'domain': domain}
|
||||
self._websocket_send('Network.setCookie', params=params)
|
||||
|
||||
def _wait_ready(self, ready_code, timeout=10):
|
||||
def _wait_ready(self, ready_code, timeout=60):
|
||||
_logger.info('Evaluate ready code "%s"' % ready_code)
|
||||
awaited_result = {'result': {'type': 'boolean', 'value': True}}
|
||||
ready_id = self._websocket_send('Runtime.evaluate', params={'expression': ready_code})
|
||||
last_bad_res = ''
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < timeout:
|
||||
tdiff = time.time() - start_time
|
||||
has_exceeded = False
|
||||
while tdiff < timeout:
|
||||
try:
|
||||
res = json.loads(self.ws.recv())
|
||||
except websocket.WebSocketTimeoutException:
|
||||
@@ -555,6 +551,11 @@ class ChromeBrowser():
|
||||
else:
|
||||
last_bad_res = res
|
||||
ready_id = self._websocket_send('Runtime.evaluate', params={'expression': ready_code})
|
||||
tdiff = time.time() - start_time
|
||||
if tdiff >= 2 and not has_exceeded:
|
||||
has_exceeded = True
|
||||
_logger.warning('The ready code takes too much time : %s' % tdiff)
|
||||
|
||||
self.take_screenshot(prefix='failed_ready')
|
||||
_logger.info('Ready code last try result: %s' % last_bad_res or res)
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user