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
  • Introduction
  • Getting Started with Tailor-Made Coding
  • Creating a Custom Class for Tailor-Made Coding
  • Configuring the CSV File
  • Usage in Testing
  • Advanced Customization
  • Conclusion

Was this helpful?

  1. Automation features

Tailor-Made Coding

Introduction

Overview

Tailor-Made Coding in Scriptless Automation empowers users to integrate custom methods into their automated test scripts, enhancing flexibility and control. By combining both API and Web testing capabilities, this approach allows for comprehensive test scenarios that involve both front-end (Web) and back-end (API) components.

Benefits

  • Custom Logic: Execute specific actions not covered by standard functionalities.

  • Enhanced Flexibility: Seamlessly integrate API responses into web tests.

  • Comprehensive Testing: Validate the complete workflow from API data handling to front-end rendering.

Prerequisites

  • Familiarity with Java and object-oriented programming.

  • Understanding of the Scriptless Automation framework.

  • Basic knowledge of both API and Web testing.

Getting Started with Tailor-Made Coding

How It Works

Custom methods are defined in user-created Java classes and referenced within the test scripts through CSV files. The framework recognizes these custom methods and executes them at the specified points in the test execution.

Example Use Case

  • Scenario: You need to fetch data via an API, store it, and use it in a web test to validate the correct rendering on a webpage.

  • Approach: Use the API_EXECUTOR action to trigger the API call, store the response in a global variable, and then use a custom method in the web test to validate the rendering based on the API data.

Creating a Custom Class for Tailor-Made Coding

Step-by-Step Guide

  1. Define the Custom Class: Create a Java class to hold your custom methods.

    package test.java;
    import main.java.com.precisiontestautomation.automation.utils.KeyInitializers;
    
    public class CustomClass {
        // Method to process API response
        public void processApiResponse() {
            String apiResponseData = KeyInitializers.getGlobalVariables().get().get("apiResponseKey");
            // Custom logic to process and validate the API response
            System.out.println("Processing API Response: " + apiResponseData);
        }
    }
  2. Integrate with Scriptless Automation: Ensure your custom class is properly structured and accessible to the Scriptless Automation framework.

Configuring the CSV File

Structure of the CSV File

The CSV file defines the steps of your test, including API execution and custom web actions. Below is the format to configure an API call followed by the use of a custom method in a web test.

Example Configuration

PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
NONE,NONE,NONE,NONE,API_EXECUTOR,fetchDataAPI,NONE,NONE
SwagLabs,VISIBILITY,NONE,usernameField,CUSTOM,CustomClass:processApiResponse,NONE,NONE
  • API_EXECUTOR: Executes an API call defined in fetchDataAPI.

  • CUSTOM: Calls the custom method processApiResponse from CustomClass.

API Execution

  • API File: Define the API details in a CSV format.

    DEPENDANT_TEST_CASE,NONE,
    END_POINT,https://api.example.com/fetchData,
    METHOD,GET,
    RESPONSE:STORE_VALUE,apiResponseKey,bodyKey
  • RESPONSE:STORE_VALUE: Stores the response data under apiResponseKey.

Usage in Testing

Running the Combined Test

Once you have configured the API and web test steps, you can run the test as part of your automation suite. The custom method processApiResponse will process the API response and validate the web page based on this data.

Practical Example

  1. API Request Execution: The framework executes the API request defined in fetchDataAPI, stores the response data in apiResponseKey.

  2. Custom Method Invocation: The framework calls processApiResponse during the web test, where it processes the API data to ensure correct rendering on the web page.

Advanced Customization

Handling Complex Scenarios

For more complex scenarios, you can extend your custom classes and methods to handle multiple API calls, perform data transformations, or integrate with additional data sources.

Example of Advanced Customization:

  • Scenario: You need to chain multiple API calls and validate data across different web pages.

    • First API call to fetch initial data.

    • Second API call to fetch additional data using the result of the first call.

    • Validation of the data across multiple pages in the web test.

    Custom Class Example:

    package test.java;
    public class CustomClass {
        public void chainApiCallsAndValidate() {
            String firstApiResponse = KeyInitializers.getGlobalVariables().get().get("firstApiResponseKey");
            // Logic to make the second API call using firstApiResponse
            String secondApiResponse = ...;
            // Store and process data for web validation
            KeyInitializers.getGlobalVariables().get().put("finalData", secondApiResponse);
        }
    }

Conclusion

Summary

Tailor-Made Coding in Scriptless Automation offers powerful customization capabilities for creating comprehensive and flexible test scenarios that span both API and Web testing. By leveraging custom Java methods and integrating them with standard automation steps, testers can ensure a thorough validation of both front-end and back-end components.

Further Resources

PreviousParallel TestingNextAutomation Demo

Last updated 10 months ago

Was this helpful?

🪶
🏗️
Scriptless Automation Documentation
YouTube Tutorial on Tailor-Made Coding