KeyInitializers
Overview
The KeyInitializers
class is a foundational component of our automated testing framework. It provides a means for users creating custom classes and methods to access and manipulate various objects and data within the framework. This class acts as a bridge between custom user-defined functionality and the core features of the framework, enabling extensive customization and flexibility in test automation.
Key Features and Usage
KeyInitializers
contains multiple ThreadLocal
instances, each serving a unique purpose. ThreadLocal is used to maintain variable values that are individual to a thread, ensuring thread safety in concurrent execution environments.
Platform, Browser, and Environment Information
Contains information about the platform, browser name, and environment (
PLATFORM
,browserName
,ENV
).Usage Example: Access browser-specific or environment-specific settings for tests.
MainWindow and Driver
Handles the main window handle (
getMainWindow
) and the WebDriver (driver
).Usage Example: Facilitates browser operations like opening URLs.
MailingServices and Response
Provides access to mailing services (
mailingServices
) and REST API responses (response
).Usage Example: Useful for tests involving email interactions and API testing.
DevToolsListener and CustomSoftAssert
Offers listeners for browser DevTools (
devToolsListener
) and custom assertion capabilities (customSoftAssert
).Usage Example: Enables advanced browser interactions and flexible assertion mechanisms in tests.
GlobalVariables
A central repository for storing and retrieving global variables (
globalVariables
).Usage Example: Store and access test data across different test cases and steps.
Personal Information Generators
Generates and stores personal information like first name (
firstName
), last name (lastName
), and phone number (phoneNumber
).Usage Example: Create mock personal data for form-filling operations in tests.
TestRunUrl
Stores the URL associated with the current test run (
testRunUrl
).Usage Example: Retrieve or set the test run's URL for reference or reporting.
Custom Class Integration
Users can create custom classes that leverage KeyInitializers
to interact with the framework's core functionalities. For instance, in the provided CustomClass
, methods are defined to perform actions like loading a URL, fetching data from global variables, and printing saved variables.
Custom Class Methods Usage Example
LoadString: Opens a specific URL using the WebDriver from
KeyInitializers
.fetchBody, getEmail, getRandomEmailBody, getSavedVariables: Retrieves and prints data from
globalVariables
.
Implementing in Test Cases
To use these custom class methods in test scenarios, you can specify them in your test configuration as shown in the example:
Web Template
Custom Class
Conclusion
KeyInitializers
is a versatile and essential class in our testing framework, enabling extensive customization and integration of user-defined functionalities. By understanding and utilizing its capabilities, users can significantly enhance the scope and effectiveness of their automated testing strategies.
Last updated
Was this helpful?