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 <jason.pike@windriver.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
}
|
@@ -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
|
||||
|
||||
|
@@ -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")
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user