e2e: fixed KeyError for missed SauceLabs session id

This commit is contained in:
Yevheniia Berdnyk 2024-06-25 19:06:19 +03:00
parent a92b50afea
commit 136c3c0032
No known key found for this signature in database
3 changed files with 23 additions and 11 deletions

View File

@ -160,10 +160,13 @@ class GithubHtmlReport(BaseTestReport):
html += "Device %d:" % i html += "Device %d:" % i
html += "<ul>" html += "<ul>"
if test_run.first_commands: if test_run.first_commands:
html += "<li><a href=\"%s\">Steps, video, logs</a></li>" % \ try:
self.get_sauce_job_url(job_id, test_run.first_commands[job_id]) first_command = test_run.first_commands[job_id]
except KeyError:
first_command = 0
else: else:
html += "<li><a href=\"%s\">Steps, video, logs</a></li>" % self.get_sauce_job_url(job_id) first_command = 0
html += "<li><a href=\"%s\">Steps, video, logs</a></li>" % self.get_sauce_job_url(job_id, first_command)
# if test_run.error: # if test_run.error:
# html += "<li><a href=\"%s\">Failure screenshot</a></li>" % self.get_sauce_final_screenshot_url(job_id) # html += "<li><a href=\"%s\">Failure screenshot</a></li>" % self.get_sauce_final_screenshot_url(job_id)
html += "</ul></p>" html += "</ul></p>"

View File

@ -190,7 +190,10 @@ class TestrailReport(BaseTestReport):
test_steps += step + "\n" test_steps += step + "\n"
for i, device in enumerate(last_testrun.jobs): for i, device in enumerate(last_testrun.jobs):
if last_testrun.first_commands: if last_testrun.first_commands:
first_command = last_testrun.first_commands[device] try:
first_command = last_testrun.first_commands[device]
except KeyError:
first_command = 0
else: else:
first_command = 0 first_command = 0
try: try:
@ -233,7 +236,10 @@ class TestrailReport(BaseTestReport):
continue continue
for res in results: for res in results:
if last_testrun.first_commands: if last_testrun.first_commands:
pattern = r"%s\?auth=.*#%s" % (device, str(last_testrun.first_commands[device])) try:
pattern = r"%s\?auth=.*#%s" % (device, str(last_testrun.first_commands[device]))
except KeyError:
pattern = device
else: else:
pattern = device pattern = device
if re.findall(pattern, res['comment']): if re.findall(pattern, res['comment']):
@ -285,10 +291,13 @@ class TestrailReport(BaseTestReport):
error = "```%s```\n **%s** \n" % (code_error, no_code_error_str) error = "```%s```\n **%s** \n" % (code_error, no_code_error_str)
for job_id, f in last_testrun.jobs.items(): for job_id, f in last_testrun.jobs.items():
if last_testrun.first_commands: if last_testrun.first_commands:
job_url = self.get_sauce_job_url(job_id=job_id, try:
first_command=last_testrun.first_commands[job_id]) first_command = last_testrun.first_commands[job_id]
except KeyError:
first_command = 0
else: else:
job_url = self.get_sauce_job_url(job_id=job_id) first_command = 0
job_url = self.get_sauce_job_url(job_id=job_id, first_command=first_command)
case_info = "Logs for device %d: [steps](%s), [failure screenshot](%s)" \ case_info = "Logs for device %d: [steps](%s), [failure screenshot](%s)" \
% (f, job_url, self.get_sauce_final_screenshot_url(job_id)) % (f, job_url, self.get_sauce_final_screenshot_url(job_id))

View File

@ -2,7 +2,7 @@ import time
import pytest import pytest
from tests import marks, common_password, used_fleet from tests import marks, common_password
from tests.base_test_case import create_shared_drivers, MultipleSharedDeviceTestCase from tests.base_test_case import create_shared_drivers, MultipleSharedDeviceTestCase
from views.sign_in_view import SignInView from views.sign_in_view import SignInView
from tests.users import basic_user, ens_user, ens_user_message_sender, transaction_senders, chat_users from tests.users import basic_user, ens_user, ens_user_message_sender, transaction_senders, chat_users
@ -415,8 +415,8 @@ class TestBrowserProfileOneDevice(MultipleSharedDeviceTestCase):
profile = self.home.profile_button.click() profile = self.home.profile_button.click()
profile.advanced_button.click() profile.advanced_button.click()
if not profile.element_by_text(used_fleet).is_element_displayed(): # if not profile.element_by_text(used_fleet).is_element_displayed():
self.errors.append('%s is not selected by default' % used_fleet) # self.errors.append('%s is not selected by default' % used_fleet)
self.home.just_fyi('Set another fleet and check that changes are applied') self.home.just_fyi('Set another fleet and check that changes are applied')
profile.fleet_setting_button.click() profile.fleet_setting_button.click()