ScriptlessAutomation
  • 👋Welcome to Scriptless Automation
  • Discover More About Automation
    • ⚙️Automation platform intro
    • 💡Advantages of Scriptless Automation
    • 🚀Release Notes
      • 📖Open Code
      • 📕License Code
  • Product tools
    • 📪Pre-request Tools
    • 🔧Project Dependencies
  • Automation Architecture
    • 🎨Flow diagram
  • Get Started
    • 🛠️Start with Automation
    • 📖Open Code Automation
      • 🌏Web Automation
      • ↔️API Automation
    • 🏢Maven Configuration
    • 🗜️Setting Up Maven Project in IntelliJ IDEA
    • 🎛️Scriptless Config
      • 🕸️BrowserConfiguration
        • chrome.properties
      • 👥CommunicationConfiguration
        • SlackConfiguration.properties
      • 📧MailConfiguration
        • gmailCredentials.properties
      • 🛂ReportConfiguration
        • extentReportConfiguration.properties
      • 🕵️TestManagementConfiguration
        • testRail.properties
        • zephyrscale.properties
        • testiny.properties
      • ⚙️testNgConfiguration.properties
    • 🍱TestData Configuration
    • 👨‍💼Gherkin Language and Scriptless Automation Framework
  • Automation Import Notes
    • 🎨Points to Remember
  • Automation Platforms
    • 👾ScriptlessApi Automation
      • 🖊️Introduction
      • 🗜️Api Automation Setup
      • 🔃Supported API Request Types
      • 🪧API Automation Template
      • 📚Example of API Requests
        • ⬇️GET
        • ↕️POST
        • ⤵️PUT
        • ❌DELETE
      • 🎯API Response Validation
      • 👨‍👦API Dependent TestCase
      • 📝Store API Variables
      • 📔API with JSON body
      • 🙋‍♂️Api Wait
      • 🗜️API Schema Validation
      • 🏗️API Tailor-Made coding
      • 👨‍🦯API Support Generator
      • ↘️Api Response Store Objects
      • ✍️API Test Report
      • 🚃Api Response Type Validation
    • 🌐ScriptlessWeb Automation
      • 🖊️Introduction
      • 🗜️Web Automation Setup
      • 🪧Web Automation Template
      • 🧮page_object_locators
      • 📜Web Automation Key Phrases
        • 📃PAGE_NAME
        • ⌛WAIT_TYPE
        • 📜SCROLL_TYPE
        • 👨‍💼ELEMENT_NAME
        • 🏎️ACTIONS
        • ⌨️SEND_KEYS
        • ✔️VALIDATION
        • ✅VALIDATION_TYPE
      • 👨‍👦Web Dependent Test Case
      • 🐒MOCK
      • 🛂AutomationAsserts
      • 🏗️Web Tailor-Made coding
      • 📝Store Web Variables
      • 🤼‍♀️Web & API integration
      • 🖇️Dynamic Strings
      • 🗣️ReadFile Annotation for Custom Code
      • 🖼️Page_Comparison
      • 👨‍💼Gherkin Template for Web Automation
    • 📱Mobile Automation
  • 🪶Automation features
    • 🌲Environment and System Variables
    • 🗝️KeyInitializers
      • Types of KeyInitializers
    • ✍️Reporting
      • Dashboard
      • Category
      • Tests
        • Screenshot Section
    • 👯Parallel Testing
    • 🏗️Tailor-Made Coding
  • ⏩Automation Demo
Powered by GitBook
On this page

Was this helpful?

  1. Automation features

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.

  1. 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.

  2. MainWindow and Driver

    • Handles the main window handle (getMainWindow) and the WebDriver (driver).

    • Usage Example: Facilitates browser operations like opening URLs.

  3. 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.

  4. 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.

  5. GlobalVariables

    • A central repository for storing and retrieving global variables (globalVariables).

    • Usage Example: Store and access test data across different test cases and steps.

  6. 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.

  7. 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

PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
NONE,NONE,NONE,NONE,LOAD_URL,https://demo.automationtesting.in/Frames.html,NONE,NONE
iframe,NONE,NONE,nestedFrame,CLICK,NONE,NONE,NONE
NONE,NONE,NONE,NONE,SWITCH_FRAME_WEB_ELEMENT,iframe:firstFrame,NONE,NONE
iframe,NONE,NONE,firstFrameElement,SAVE,testFrameName,NONE,NONE
NONE,NONE,NONE,NONE,CUSTOM,CustomClass:getSavedVariables,NONE,NONE

Custom Class

package test.java;

import main.java.com.precisiontestautomation.automation.utils.KeyInitializers;

public class CustomClass {

    public void getSavedVariables(){
        System.out.println(KeyInitializers.getGlobalVariables().get().get("testFrameName"));
    }
}

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.

PreviousEnvironment and System VariablesNextTypes of KeyInitializers

Last updated 1 year ago

Was this helpful?

🪶
🗝️