🙋‍♂️Api Wait

Introduction

The API Wait feature in scriptless automation is designed to synchronize the automation flow with the readiness of the API response. It allows the automation to pause execution until the API response contains a specific expected value, or until a specified timeout is reached.

How to Use API Wait

Setting Up API Wait

The API Wait feature is only applicable for the combination of RESPONSE:EXPECTED_VALUE and RESPONSE:JSON_PATH at column index 1. This specific pairing ensures the automation framework knows precisely which value to await and where to find it in the API response.

In the CSV template, you can specify the expected value within the RESPONSE:EXPECTED_VALUE column, along with an optional timeout value. The automation framework will wait for the response from the API to match this expected value before proceeding.

CSV Template Syntax

RESPONSE:JSON_PATH,'Column Name',additionalField
RESPONSE:EXPECTED_VALUE,ExpectedValue:Timeout,NONE
  • RESPONSE:JSON_PATH: Indicates the JSON path where the expected value is to be found in the API response.

  • RESPONSE:EXPECTED_VALUE: Specifies the expected value and an optional timeout in seconds.

Example Without Custom Timeout

DEPENDANT_TEST_CASE,NONE,
...
BODY:KEY,JsonRepository,name
BODY:VALUE,test,PrecisionTestAutomation
RESPONSE:CODE,201,
RESPONSE:JSON_PATH,'Column 1',id
RESPONSE:EXPECTED_VALUE,PrecisionTestAutomation,NONE
RESPONSE:STORE_VALUE,NONE,ID

In this example, the automation framework will wait for the value PrecisionTestAutomation to appear in the response under Column 1. The default timeout is 30 seconds.

Example With Custom Timeout

...
RESPONSE:JSON_PATH,'Column 1',id
RESPONSE:EXPECTED_VALUE,PrecisionTestAutomation:10,NONE
...

Here, :10 appended to the PrecisionTestAutomation indicates that the automation should wait for up to 10 seconds for the expected value.

API Wait Feature Benefits

  • Synchronization: Ensures that the automation flow is in sync with the processing time of the API, preventing failures due to premature assertions.

  • Customizable Wait: Allows setting a custom timeout to accommodate APIs with variable response times.

  • Fail-fast Mechanism: Provides an early exit if the expected value does not appear in the API response within the timeout, enhancing test efficiency.

Conclusion

The API Wait feature adds an intelligent waiting mechanism to scriptless automation, enhancing the accuracy and reliability of API testing. By focusing on the first column index for expected values and JSON paths, it introduces a standardized method to manage asynchronous API responses effectively. This feature is critical for ensuring that automation processes remain stable and consistent, particularly in complex, data-dependent testing scenarios.

Last updated

Was this helpful?