API Keywords
Background
Swagger is a tool for defining, developing, and debugging APIs such as RESTful. Swagger can be used to define API attributes in a standardized manner, facilitating interconnection and interworking. API automation allows you to import API description files in Swagger 2.0 &3.0 format, parse API definition descriptions, and generate a script template. You only need to enter API parameters based on the template to create API automation test cases.
You can import a Swagger API description file to generate a script template. A script template corresponds to an API definition in the Swagger file. Test cases can be orchestrated in a visualized manner based on the script template.
The mapping between the script template and the fields in the Swagger API description is as follows.
- swagger 2.0 standard :
Script Template Attribute
Swagger API Definition Attribute
Name
By default, operationId is used. You can set it to summary.
Path
schema + :// + basePath + path.
Request parameter hostURL
host
Other request parameters
parameters
- swagger 3.0 standard :
Script Template Attribute
Swagger API Definition Attribute
Name
By default, operationId is used. You can set it to summary.
Path
url + path.
Request parameter hostURL
servers:
- url: https://{hostURL}/variable
variables:
hostURL:
default: test.huawei.com
Other request parameters
parameters, requestBody, responses
Importing a Swagger File to Generate a Test Script
- After the operations described in Creating an API Automation Test Case are complete, click the test case name, and click the Scripting tab.
- In the Action Word Lib area on the right of the page, click Import API.
- Click Click to add file or drag upload, select the configured Swagger API file, and click ok.
- After the file is imported successfully, the system automatically parses and generates a script template. The script template contains the basic description of the API. You only need to enter the API parameters based on the template to perform the test.
Saving a Customized API Keyword
- After the operations described in Creating an API Automation Test Case are complete, click the API automation test case name and click the Scripting tab.
- After the operations described in Writing an API Automation Script are complete, select the test step to be set as a keyword (only for custom URL request steps), and click
at the upper right corner of the test step page to save the API keyword.
- On the page that is displayed, set API Keyword and Description, and select the directory for storing the keyword. By default, keywords are stored in Default Folder under .
- Click Save.
For an added keyword, you can hover the cursor over the keyword area and perform the following operations:
- Click a keyword name to view the details about the keyword.
- Click
on the right of the Keyword to create a folder. Save the keyword set in Step 3 to a custom folder.
- Hover the cursor over the left area of a keyword name to adjust the keyword sequence.
- Click
or hover the cursor over the keyword and drag it to the blank page of the test step to add a test step as a keyword.
- Click any area of the test keyword to edit the keyword pair application case details.
- Click
to view the information about the step.
- Click
to disable a keyword, and click it again to enable the keyword.
- Click
to delete a keyword from the script.
Feedback
Was this page helpful?
Provide feedbackFor any further questions, feel free to contact us through the chatbot.
Chatbot