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
Define the Custom Class: Create a Java class to hold your custom methods.
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
API_EXECUTOR: Executes an API call defined in
fetchDataAPI
.CUSTOM: Calls the custom method
processApiResponse
fromCustomClass
.
API Execution
API File: Define the API details in a CSV format.
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
API Request Execution: The framework executes the API request defined in
fetchDataAPI
, stores the response data inapiResponseKey
.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:
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
Last updated
Was this helpful?