QLTY Utilities
Handy modules, methods and functions to help you with your tests
Argument parser
- class argument_parser.QLTYArgumentParser
Command line argument parser for the QLTY test execution framework
- __init__()
Initialize argument parser and process command line inputs
- _parse_arguments()
Processes command line arguments and maps them to configuration settings
- _prepare_arguments()
Configures all supported command line arguments for the parser
- _print_arguments()
Outputs current configuration state for debugging purposes
- _validate_arguments()
Validates that required settings exist in settings.py for selected integrations
Selenium utilities
- selenium_utils.ensure_chromedriver(chromedriver_path)
Ensures a compatible ChromeDriver is available at the given path. Always runs the fetch script to verify version compatibility with installed Chrome. The script exits early if the existing ChromeDriver already matches.
- selenium_utils.get_desktop_webdriver()
Creates desktop browser webdriver instance from drivers directory
- selenium_utils.initialize_driver(test_case, platform, force_driver_creation=True)
Initializes appropriate driver based on platform and configuration
- Parameters:
test_case – A QLTY test case for retrieving class and method names
platform – Platform identifier string for webdriver selection
force_driver_creation – Override configuration to force driver initialization
- Type:
QLTYTestcase
- Type:
String
- selenium_utils.perform_action_on_picker_wheel(driver, web_element, direction)
Manipulates iOS picker wheel element
- Parameters:
driver (WebDriver) – Active driver instance
web_element (WebElement) – Target web element
direction (str) – Navigation direction:
NextorPrevious
- selenium_utils.perform_tap_back(driver)
Executes back navigation action
- selenium_utils.perform_tap_based_on_cords(driver, coords)
Executes tap gesture using absolute viewport coordinates
- selenium_utils.perform_tap_location(driver, offset)
Executes tap gesture using percentage-based coordinates
- Parameters:
driver (WebDriver) – Active driver instance
offset (dict) – Coordinate dictionary with offset_x and offset_y percentages
- selenium_utils.switch_to_native_context(driver)
Returns to native app context from web view
- Parameters:
driver (WebDriver) – Active driver instance
- Returns:
None
- selenium_utils.wait_for_web_context(driver, webview_name)
Waits until specified web view becomes available and switches context to it
- Parameters:
driver (WebDriver) – Active driver instance
webview_name (str) – Target webview identifier
Utilities
- utils.ANDROID_SWIPE_OFFSETS = {'down': {'end_x': 0.5, 'end_y': 0.45, 'start_x': 0.5, 'start_y': 0.9}, 'down_40_percent': {'end_x': 0.5, 'end_y': 0.9, 'start_x': 0.5, 'start_y': 0.5}, 'up': {'end_x': 0.5, 'end_y': 0, 'start_x': 0.5, 'start_y': 0.9}, 'up_10_percent': {'end_x': 0.5, 'end_y': 0.7, 'start_x': 0.5, 'start_y': 0.8}, 'up_30_percent': {'end_x': 0.5, 'end_y': 0.5, 'start_x': 0.5, 'start_y': 0.8}}
Predefined coordinate offsets for Android swipe gestures
- utils.BUILD_ID = 'cba13d'
Unique identifier for current test execution session
- utils.CURRENT_TEST_RUN_ID = None
Global reference to current test session identifier
- utils.IOS_SWIPE_OFFSETS = {'left': {'direction': 'left'}, 'middle_swipe': {'end_x': 0, 'end_y': 0.5, 'start_x': 1, 'start_y': 0.5}, 'up': {'direction': 'up'}}
Predefined coordinate offsets for iOS swipe gestures
- utils.dump_logs(results_dir, driver)
Extracts and saves logs to the test method results directory
- Parameters:
results_dir (str) – Full path to test method results directory
driver (WebDriver) – Appium webdriver instance for log extraction
- utils.dump_screenshot(results_dir, test_case, driver)
Captures and saves screenshot when test case fails
- Parameters:
results_dir (str) – Full path to test method results directory
test_case (QLTYTestCase) – A QLTY test case instance
driver (WebDriver) – Appium webdriver instance for screenshot capture
- utils.dump_test_results(test_case)
Generates directory structure for storing individual test case results
- Parameters:
test_case (QLTYTestCase) – A QLTY test case instance
- Returns:
Absolute path to the test method results directory
- Return type:
str
- utils.exists(var)
Validates variable existence, useful for checking undefined attributes The variable must be passed as a reference using lambda to prevent immediate AttributeError:
exists(lambda:my_variable)
- Parameters:
var – Variable reference to validate
- Returns:
True if variable exists, None otherwise
- Return type:
bool
- utils.get_unique_build_id()
Generates a unique build identifier for this test execution session
- Returns:
Unique build identifier string
- Return type:
String
- utils.get_uuid()
Generates a unique identifier using Python’s uuid library
- Returns:
Shortened unique 6-character identifier
- Return type:
str
- utils.is_browser_run(platform)
Determines if current test execution targets desktop browsers
- Parameters:
platform (String) – Platform type identifier string
- Returns:
True if execution targets desktop browser
- Return type:
bool
- utils.setup_logger(name, debug_level)
Creates and configures a logger instance with color formatting.
- Parameters:
name (str) – Logger identifier prefix for the formatter
debug_level (int) – Logging verbosity level
- Returns:
Configured logger instance for the calling module
- Return type:
logger
Configuration
Framework configuration settings module Contains framework-wide parameters that apply across all test implementations
- config.CURRENT_ENVIRONMENT = None
Selected environment key from settings.ENVIRONMENTS
- config.CURRENT_PLATFORM = None
Current execution platform identifier
- config.DESKTOP_BROWSER = False
Execute tests using desktop browsers via Selenium only (no Appium)
- config.EXCLUDE_TAG = None
Exclude tests with this tag
- config.EXCLUDE_TESTS = []
List of test class names to exclude from execution
- config.HEADLESS = False
Run browser in headless mode (no UI)
- config.INCLUDE_TAG = None
Run only tests with this tag (e.g. ‘production’, ‘smoke’)
- config.MANAGED_DRIVERS = False
Use automated driver management for browser drivers
- config.MOBILE_BROWSER = False
Execute tests targeting mobile web browsers
- config.PROJECT_FRIENDLY_NAME = 'QLTYMobileFramework/1.0'
Application identifier string
- config.REPORT_ON_FAIL = False
Allow reporting functionality even when test cases fail
- config.RUNNING_ON_JENKINS = False
Indicates execution within Jenkins CI environment
- config.SAUCELABS_INTEGRATION = False
Enable SauceLabs cloud testing platform integration
- config.SINGLE_TEST_NAME = None
Specify individual test case to execute
- config.SLACK_REPORTING = False
Enable Slack notification integration for test results
- config.TESTRAIL_INTEGRATION = False
Enable TestRail test management integration for result reporting