From 3a955b140be2dadceaa642dd41742ecb85b4aa9b Mon Sep 17 00:00:00 2001 From: BanulaMahen Date: Sat, 11 Mar 2023 22:21:58 +0530 Subject: [PATCH] #200 Fixing Unit test failure - test_archive_license_requests_feature --- src/app/tests.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/tests.py b/src/app/tests.py index 3ae142d7..946b3b03 100644 --- a/src/app/tests.py +++ b/src/app/tests.py @@ -16,6 +16,7 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.firefox.options import Options +from selenium.common.exceptions import NoSuchElementException from webdriver_manager.firefox import GeckoDriverManager import time @@ -1115,11 +1116,11 @@ def test_archive_license_requests_feature(self): license_name = driver.find_element_by_css_selector('td').text self.assertEqual(license_name, "BSD Zero Clause License-00") self.assertEqual(LicenseRequest.objects.get(id=license_obj.id).archive, False) - if driver.find_element_by_id('archive_button' + str(license_obj.id)): + try: driver.find_element_by_id('archive_button' + str(license_obj.id)).click() driver.find_element_by_id('confirm_archive').click() self.assertEqual(LicenseRequest.objects.get(id=license_obj.id).archive, True) - else: + except NoSuchElementException: pass @skipIf(not getAccessToken() and not getGithubUserId() and not getGithubUserName(), "You need to set gihub parameters in the secret.py file for this test to be executed properly.")