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
  • Prerequisites
  • Project Setup
  • Configuration
  • IntelliJ IDEA Setup
  • Conclusion
  • Next Steps

Was this helpful?

  1. Get Started
  2. Open Code Automation

API Automation

Introduction

This guide provides a step-by-step process to set up and run a Maven project with Scriptless Automation for API testing. It includes adding dependencies, configuring plugins, and setting up the necessary configurations for API automation.

Prerequisites

Before you begin, ensure you have the following installed on your system:

  • Java Development Kit (JDK)

  • Apache Maven

  • IntelliJ IDEA (or any preferred IDE)

Project Setup

1. Create a Maven Project

Create a new Maven project in your IDE or via the command line.

2. Add Dependencies

Add the Scriptless Automation dependency for API testing to your pom.xml file:

<dependencies>
  <dependency>
    <groupId>in.precisiontestautomation.scriptlessautomation</groupId>
    <artifactId>scriptlessautomation-api</artifactId>
    <version>LATEST</version>
  </dependency>
</dependencies>

3. Add Plugins

Add the following plugins to your pom.xml file to configure the execution of the main class and testing framework:

<plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
      <execution>
        <goals>
          <goal>java</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <mainClass>in.precisiontestautomation.runner.ScriptlessApplication</mainClass>
      <arguments>
        <argument>true</argument>
      </arguments>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M4</version>
    <configuration>
      <argLine>-XX:+ExplicitGInvokesConcurrent</argLine>
      <argLine>--add-opens java.base/java.lang.reflect=ALL-UNNAMED</argLine>
      <testFailureIgnore>false</testFailureIgnore>
      <suiteXmlFiles>
        <suiteXmlFile>target/testngenerator.xml</suiteXmlFile>
      </suiteXmlFiles>
    </configuration>
  </plugin>
</plugins>

Configuration

4. Add Scriptless Configuration

To execute Scriptless Automation for API testing, add the following configuration files in your project:

project
 └── config
     ├── reportConfiguration
     │   └── extentReportConfiguration.properties
     └── testNgConfiguration.properties

4.1 reportConfiguration/extentReportConfiguration.properties

This file contains the configuration settings for the Extent Reports.

# Extent Report Configuration
ReportName = AutomationReport

#DARK , STANDARD
Report_Theme = DARK
Report_JS = for (let e of document.querySelectorAll (".details-col")) { e.innerHTML ='Steps' };
Report_CSS = .header .vheader .nav-logo>a .logo {min-height: 52px;min-width: 52px;}
Report_logo = "/config/logo.jpg"
Report_captureScreenshotOnPass = true

4.2 testNgConfiguration.properties

This file contains the TestNG configuration settings.

# TestNG Configuration
ReportName = AutomationReport
Env = sandbox
ThreadCount= 2

FAILED_RETRY_COUNT=0
SET_TEST_SUITE_NAME = Scriptless
SET_TEST_NAME = Regression Testing

TEST_DATA_SECTIONS=All
TEST_IDS=All
DISABLE_TEST_IDS=

GROUPS=All

5. Add Test Data

Add the necessary test data to your project. This involves creating a directory structure to store test data files and ensuring they are accessible to your test scripts. Use the following directory structure:

project
   └── test_data
       └── API
           ├── JsonRepository
           │   └── file.json
           ├── test_case_flows
           │   └── TestDirectory
           │       └── TestID_GroupName.csv
           └── schemaJson
               └── schema.json        

5.1 test_data/API/JsonRepository/

This file contains the JSON payloads for your API tests.

{
  "exampleKey": "exampleValue"
}

5.2 test_data/API/test_case_flows/TestDirectory/

This file contains test case flows and steps for each test. Each directory under test_case_flows represents a feature.

# Example test case flow
DEPENDANT_TEST_CASE,NONE,
END_POINT,https://api-generator.retool.com/vEQvcT/data,
METHOD,POST,
PARAMS:KEY,NONE,
PARAMS:VALUE,NONE,
AUTH:KEY,NONE,
AUTH:VALUE,NONE,
HEADERS:KEY,Content-Type,
HEADERS:VALUE,application/json,
BODY:KEY,JsonRepository,name
BODY:VALUE,test,Custom:CustomClass:body
RESPONSE:CODE,201,
RESPONSE:SCHEMA,putSchema.json
RESPONSE:JSON_PATH,'Column 1',id
RESPONSE:EXPECTED_VALUE,ApiGlobalVariables:name,NONE
RESPONSE:STORE_VALUE,Name,ID

5.3 test_data/API/test_case_flows/schemaJson/

This file performs schema validation against the response generated by the API request

{
  "Column 1": "ApiGlobalVariables:name",
  "id": "@Integer"
}

IntelliJ IDEA Setup

6. Add IntelliJ Run Configuration

Create a run configuration in IntelliJ IDEA to run your Maven project. Follow these steps:

  1. Go to Run > Edit Configurations.

  2. Click on the + icon and select Application.

  3. Set the name for your configuration (e.g., runner).

  4. Click on Apply

7. Run CLI Command

To execute the project, use the following CLI command:

mvn clean exec:java test

This command will run the main class defined in the exec-maven-plugin configuration.

Conclusion

By following this guide, you have set up a Maven project with Scriptless Automation for API testing. You configured the necessary dependencies, plugins, and run configurations to execute your API automation tests.

Next Steps

  • Customize your test scripts according to your API requirements.

  • Explore more features of Scriptless Automation to enhance your test coverage.

  • Integrate additional tools and frameworks as needed for comprehensive test automation.

PreviousWeb AutomationNextMaven Configuration

Last updated 1 year ago

Was this helpful?

📖
↔️