Assertion and Validation
Overview
WebRunner provides assertion utilities for validating WebDriver and WebElement states
during automation. If a check fails, a WebRunnerAssertException is raised.
WebDriver Validation
Validate properties of the current WebDriver:
# Via WebDriverWrapper
wrapper.check_current_webdriver({"name": "chrome"})
# Via utility functions
from je_web_runner.utils.assert_value.result_check import (
check_webdriver_value,
check_webdriver_values,
)
check_webdriver_value("name", "chrome", webdriver_instance)
check_webdriver_values({"name": "chrome"}, webdriver_instance)
WebElement Validation
Validate properties of the current WebElement:
# Via WebElementWrapper
web_element_wrapper.check_current_web_element({
"tag_name": "input",
"enabled": True
})
# Via utility functions
from je_web_runner.utils.assert_value.result_check import check_web_element_details
check_web_element_details(element, {
"tag_name": "input",
"enabled": True
})
General Value Checking
from je_web_runner.utils.assert_value.result_check import check_value, check_values
# Check a single value against a result dictionary
check_value("element_name", "expected_value", result_check_dict)
# Check multiple values
check_values({"name": "expected"}, result_check_dict)
Via Action Executor
from je_web_runner import execute_action
execute_action([
["WR_get_webdriver_manager", {"webdriver_name": "chrome"}],
["WR_check_current_webdriver", {"check_dict": {"name": "chrome"}}],
["WR_quit"],
])
Functions Reference
Function |
Description |
|---|---|
|
Check a single value against a result dictionary |
|
Check multiple key-value pairs |
|
Check a single WebDriver property |
|
Check multiple WebDriver properties (alias: |
|
Validate WebElement properties against expected values |