From aa8455778d4ceb7f84e559907a32b8178db670d4 Mon Sep 17 00:00:00 2001 From: jpike Date: Wed, 20 Aug 2025 11:03:33 -0400 Subject: [PATCH] Adding back files missing from previous commit These files were missing from the previous commit. They allow users to maximize a browser by config and add in a new validation. Change-Id: I3440a1659f2719486fd3b9f6232a26ec538c26a9 Signed-off-by: jpike --- config/web/files/default.json5 | 1 + config/web/objects/web_config.py | 12 ++++++++++++ framework/validation/validation.py | 24 ++++++++++++++++++++++++ framework/web/webdriver_core.py | 26 ++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/config/web/files/default.json5 b/config/web/files/default.json5 index 50c6d3f7..07eca310 100644 --- a/config/web/files/default.json5 +++ b/config/web/files/default.json5 @@ -1,5 +1,6 @@ { // Set to true if we want to run web tests in headless mode. If set to false, the browser will be launched to run the UI tests. "run_headless": true, + "start-maximized": true, } \ No newline at end of file diff --git a/config/web/objects/web_config.py b/config/web/objects/web_config.py index a89078a8..50e523e4 100644 --- a/config/web/objects/web_config.py +++ b/config/web/objects/web_config.py @@ -16,9 +16,21 @@ class WebConfig: web_dict = json5.load(json_data) self.run_headless = web_dict['run_headless'] + self.start_maximized = web_dict['start-maximized'] def get_run_headless(self) -> bool: """ Getter for run_headless; Set this to false if you want to see UI tests run in a browser. """ return self.run_headless + + def get_start_maximized(self) -> bool: + """ + Getter for start_maximized; Set this to true if you want the browser to be maximized. + + Returns: + bool: True if we are running maximized. + + """ + return self.start_maximized + diff --git a/framework/validation/validation.py b/framework/validation/validation.py index f0a5db2d..a9de5c4b 100644 --- a/framework/validation/validation.py +++ b/framework/validation/validation.py @@ -262,3 +262,27 @@ def validate_list_contains_with_retry( # Move on to the next iteration else: raise TimeoutError(f"Timeout performing validation - {validation_description}") + + +def validate_greater_than(observed_value: int, baseline_value: int, validation_description: str) -> None: + """ + This function will validate if the observed value is greater then the baseline value. + + Args: + observed_value (int): Value that we see on the system. + baseline_value (int): Value that we want to see if the observed value is greater than + validation_description (str): Description of this validation for logging purposes. + + Returns: None + + Raises: + Exception: raised when validate fails + + """ + if observed_value > baseline_value: + get_logger().log_info(f"Validation Successful - {validation_description}") + else: + get_logger().log_error(f"Validation Failed - {validation_description}") + get_logger().log_error(f"Baseline: {baseline_value}") + get_logger().log_error(f"Observed: {observed_value}") + raise Exception("Validation Failed") \ No newline at end of file diff --git a/framework/web/webdriver_core.py b/framework/web/webdriver_core.py index 8d7b3f15..392a63dc 100644 --- a/framework/web/webdriver_core.py +++ b/framework/web/webdriver_core.py @@ -9,6 +9,7 @@ from framework.logging.automation_logger import get_logger from framework.web.action.web_action_click import WebActionClick from framework.web.action.web_action_get_text import WebActionGetText from framework.web.action.web_action_hover import WebActionHover +from framework.web.action.web_action_is_exists import WebActionIsExists from framework.web.action.web_action_send_keys import WebActionSendKeys from framework.web.action.web_action_set_text import WebActionSetText from framework.web.condition.web_condition import WebCondition @@ -31,6 +32,8 @@ class WebDriverCore: chrome_options.add_argument("--ignore-certificate-errors") if ConfigurationManager.get_web_config().get_run_headless(): chrome_options.add_argument("--headless") + if ConfigurationManager.get_web_config().get_start_maximized(): + chrome_options.add_argument("--start-maximized") self.driver = webdriver.Chrome(options=chrome_options) def close(self) -> None: @@ -42,6 +45,15 @@ class WebDriverCore: """ self.driver.close() + def quit(self) -> None: + """ + Quit the WebDriver + + Returns: None + + """ + self.driver.quit() + def navigate_to_url(self, url: str, conditions: List[WebCondition] = []) -> None: """ This function will navigate to the specified url. @@ -177,3 +189,17 @@ class WebDriverCore: action = WebActionGetText(self.driver, locator, conditions) action_executor = WebActionExecutor(action) return action_executor.execute_mass_action() + + def is_exists(self, locator: WebLocator) -> bool: + """ + Checks for existence of the locator + Args: + locator (WebLocator): the locator + + Returns: + bool: Returns True if the element exists, False otherwise + + """ + action = WebActionIsExists(self.driver, locator) + action_executor = WebActionExecutor(action) + return action_executor.execute_action()