Becoming an Expert
API Test Automation
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
API Automation Capability Overview
▪ Integrated, 3600 approach to API testing
▪ Consistent, natural language approach to API validation
▪ Ability to setup Regression test plans for API testing
▪ Combine API and UI validation in one test flow
▪ Support for Protocols: REST (Put, Get, Post, Delete
methods) and SOAP
▪ Wizard based approach for further ease of logic
development with API
▪ Extensive Json and XML verifications for advanced logic
development
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Basic Glossary of API Testing
API
Application Programming Interface. Enables different systems to interact with each other programmatically.
BASE PATH RESPONSE STATUS CODE
URL common to all the resources being requested from a given Indicates the Request’s overarching result. 40 different status
API service. codes possible. 200 is the most common Success code.
END POINT
RESPONSE HEADERS
Path of the resource being requested via API.
Note: Endpoint URL in ACCELQ should include the base path as well. Indicates the metadata returned as part of the Response to the
Request. Returned as name/value pairs.
METHOD
Indicates the type of interaction (such as GET, POST, or DELETE) RESPONSE BODY
with the resource. Applicable for REST only.
Information returned by an API after a request is made.
Responses are usually in either JSON or XML format.
REQUEST HEADERS
Parameters that are included in the request header. Specified as
SPECIFICATION FILE
name/value pairs
File that describes the API service. Services available, request
formats, response samples etc.
REQUEST BODY (PAYLOAD)
Parameters that are included in the request body. Usually
submitted as JSON or XML. WSDL for SOAP and Swagger, SAML, RAML etc. for REST
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Note on Library Context and API-Only Scenarios
Library Context
▪ Library Context is typically useful when
you want to build logic only for API and
back-end automation (without any UI
verifications)
▪ Makes it convenient to use Actions in
Scenarios in any order, as required.
Scenario Builder
▪ When building an API-only Scenario (a
scenario that does not include any UI
steps), you can skip the Scenario Builder
by clicking Create Scenario with Library or API
steps link.
▪ Allows creating Scenarios without the first
Initialize step.
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
3 Steps to REST API Verification
Step 1: Provide End Point URL,
Method Type and Request Headers
Reference Name for further logic development
Step 2: Select Payload Type and
provide Request Payload
For all methods, except GET.
Step 3: Review Response and
incorporate Verification as needed
Verify status, headers and response body
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Example 1: REST API Test / Post method
Objective: Login to Qbank and authenticate
Request Details
• End Point: https://qbankserver.accelq.com/api/login
• Method Type: POST
• Headers: None
• Payload: {"username" : "qbankadmin", "password" : "pass123" }
Response Verification
Verify following information
• Status: 200
• Header “Server” is “Cowboy”
• Response Body: Verify following nodes:
• name: Thomas
• email: aq1510724390@mailinator.com
• phone: [0-9]{10}*
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Example 2: Parameterizing REST Request / Response
Objective: Parameterize REST
Request information and the
verification information, so that
same Action can be used for
multiple users.
Parameters for Request:
• User Name
• Password
Parameters for Response
• Expected Name
• Expected Email
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Example 3: Extracting information from REST call response
Objective: Extract authentication token from login API call
Step 1: Create REST API call using the wizard for authentication call.
Step 2: In the Response screen of the wizard, copy the JSON Path for
the required node. $['accessToken']
Step 3: Save API statements from the wizard.
Step 4: Insert command in logic editor to read information from the
Response node.
Get Node from ReST Response
• Reference name of REST call
• JSON Path
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Chaining API Calls
API chaining allows making a series of API calls, which are dependent on each other (for data) to achieve a complete business
objective. Response parameters (including header and response body) from one API call forms an input (Request headers or Request
parameters) for subsequent calls.
Typical example may be trying to access a resource that requires authentication.
• You make an API call for authentication, and retrieve authentication token.
• Using this authentication token as part of the Request parameter, you make another API call to retrieve a resource from the
service.
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Example 4: Chaining API Calls
Objective Extract Total Balance of a customer after authenticating on QBank
Step 1: Extract authentication token from Authentication API as in previous example.
Step 2: Insert a new REST call with following information
• End Point: https://qbankserver.accelq.com/api/totalbalance
• Method Type: GET
• Headers: access_token = <from step 1>
• Payload: N/A
Step 3: Get total balance from REST call (body of response) using the following command
Get ReST Response
• Reference name of REST call
Note
When using parameters in the Request headers or Request body, in the wizard, you will be required to furnish sample values to proceed to
next step.
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Example 4: Chaining API Calls
Note
Notice how the authentication token is linked in Step #2 from Step #1
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Example 5: Bringing UI and API together
Objective Extract account balance from
API call and verify against the display in
QBank application UI.
Step 1: Extract authentication token from
Authentication API as in Example 3.
Step 2: Get Account balance as in
Example 4
Step 3: Initialize Qbank login page
Step 4: Login to Qbank from the UI
Step 5: Verify balance on screen with API
balance
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Building API Logic without a working API implementation
API Wizard allows you to build API test logic when the API is not accessible or even if the service is still under development.
• In the Wizard, API call will fail and display empty Response.
• Load a sample Response from a file and insert verifications as you would normally do.
• Complete end-to-end flow can be developed without the working API implementation.
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Useful Commands in REST Response Processing
GET STATUS CODE FROM REST RESPONSE
GET REST RESPONSE
VERIFY REST RESPONSE STATUS CODE
Returns the JSON or XML response from the REST API call,
identified with the reference name. You can utilize this content to
Returns or verifies the status code from a given REST call, identified with make further processing
Reference name.
GET REST RESPONSE HEADER ADVANCED VERIFICATIONS
VERIFY REST RESPONSE HEADER When you need advanced verifications on the Response, get the
entire response in a parameter using GET REST RESPONSE
Returns or verifies the value of a given Header resulting from a REST API call,
and utilize JSON/XML libraries for parsing and custom
identified with its reference name.
verifications.
GET NODE FROM REST RESPONSE
VERIFY NODE IN REST RESPONSE
Returns or verifies the value of a node in REST response body. REST call is
identified with the reference name and the Node is identified with standard
JSON Path string.
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
4 Steps to SOAP Verification
Step 1: Provide WSDL URL or point to a
WSDL file
WSDL file is optional
Step 2: Provide End Point URL and
Request Headers
Reference Name for further logic development
Step 3: Provide Request Payload
XML format
Step 4: Review Response and incorporate
Verification as needed
Verify status, headers and response body
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
Example 6: SOAP API Test
Objective
Use a calculator service to multiply two numbers.
REST API details
• WSDL URL: http://www.dneonline.com/calculator.asmx?WSDL
• Method: Multiply
• Headers: None (be sure to delete the auto-created header in the screen)
• Payload: Provide values for first number and second number to multiply
Verification
Verify the result of multiplication
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com
API Wizard communication with API Service
When you are using the API wizard
When you are in API wizard, calls to the API service are sent from
ACCELQ server, by default. If you are a Cloud customer, ACCELQ
server may or may not be able to interact with your API service
resulting in connection failure.
You can switch to Browser based communication with API
service, as an option. If you encounter CORS errors with this
setting, please contact your network admin.
When tests are actually executing, API communication happens directly from the
Note:
Local Agent, which is running inside your firewall. Browser-based communication
option is only relevant when using the wizard in Action logic.
Proprietary & Confidential. Copyright 2023, ACCELQ Inc.. www.accelq.com