Skip to content

Commit 2bd4187

Browse files
test: Refactor US05 test methods for improved readability and error handling
1 parent 4a7f17d commit 2bd4187

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/us5.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
\
21
import unittest
32
import os
43
import time
@@ -83,7 +82,8 @@ def _take_screenshot(self, name_suffix):
8382
logger.info(f"Screenshot saved: {screenshot_name}")
8483
except Exception as e:
8584
logger.error(f"Error saving screenshot {screenshot_name}: {e}")
86-
def _set_approval_grade(self, approval_grade_value):
85+
86+
def _set_approval_grade(self, approval_grade_value):
8787
logger.info(f"Setting approval grade to: {approval_grade_value} using JavaScript injection")
8888
# Instead of navigating to settings, set the approval grade directly using JavaScript
8989
# This is more reliable and faster than navigating through the UI
@@ -158,7 +158,9 @@ def _get_required_grade_or_message(self):
158158
except Exception as e:
159159
logger.error(f"Error getting required grade/message: {e}", exc_info=True)
160160
self._take_screenshot("get_required_grade_error")
161-
return "Error: General" def _initial_setup(self):
161+
return "Error: General"
162+
163+
def _initial_setup(self):
162164
if not hasattr(self, 'driver') or not self.driver:
163165
logger.error("Driver not initialized in _initial_setup. Aborting setup.")
164166
self.fail("Driver not initialized for test setup.")
@@ -358,7 +360,9 @@ def _add_grade_and_percentage(self, grade, percentage):
358360
logger.error(f"Could not find input elements in the grade row: {e}")
359361
self._take_screenshot("input_elements_not_found")
360362
self.fail(f"Input elements not found: {e}")
361-
return def _click_calculate_and_wait_for_result_page(self):
363+
return
364+
365+
def _click_calculate_and_wait_for_result_page(self):
362366
calculate_button = self.wait_long.until(EC.element_to_be_clickable((By.CSS_SELECTOR, self.CALCULATE_BUTTON_SELECTOR)))
363367
calculate_button.click()
364368
self.wait_long.until(EC.presence_of_element_located((By.CSS_SELECTOR, self.RESULT_PAGE_CONTAINER_SELECTOR)))

0 commit comments

Comments
 (0)