Don't fail integration tests if browser log couldn't be retrieved

Firefox will throw an "HTTP method not allowed" error randomly when
trying to retrieve the browser log. This change will prevent the
selenium test from failing when that happens, and instead logs
the exact exception that happened as the content of that log.

Change-Id: I3384c3cfdf87f475bf62b2df6b895569723eb187
This commit is contained in:
Radomir Dopieralski 2021-02-03 21:00:48 +01:00
parent 944902c5c2
commit b07ed28a9b
1 changed files with 6 additions and 4 deletions

View File

@ -254,10 +254,12 @@ class BaseTestCase(testtools.TestCase):
def _attach_browser_log(self, exc_info=None):
browser_log_path = os.path.join(self._test_report_dir, 'browser.log')
with self.log_exception("Attach browser log"):
with open(browser_log_path, 'w') as f:
f.write(
self._unwrap_browser_log(self.driver.get_log('browser')))
try:
log = self._unwrap_browser_log(self.driver.get_log('browser'))
except Exception:
log = traceback.format_exc()
with open(browser_log_path, 'w') as f:
f.write(log)
def _attach_test_log(self, exc_info=None):
test_log_path = os.path.join(self._test_report_dir, 'test.log')