Академический Документы
Профессиональный Документы
Культура Документы
1
Survey
SURVEY
Tricentis Automation Specialist for API
Student Exercise Workbook
• Version 2019
• Designed to be used with Tricentis Tosca version 12.x
Legal Notice
Tricentis GmbH
Leonard-Bernstein-Straße 10
1220 Vienna
Austria
Tel.: +43 (1) 263 24 09
Fax: +43 (1) 263 24 09-15
Email: academy@tricentis.com
Information in this document is subject to change without notice. No part of this document may be reproduced or
transmitted in any form or by any means, electronic or mechanical, for any purpose without the express written permission
of Tricentis GmbH.
2
TABLE OF CONTENTS
SURVEY............................................................................................................................................. 2
Student Exercise Workbook.................................................................................................................................................. 2
Legal Notice. ......................................................................................................................................................................... 2
TABLE OF CONTENTS...................................................................................................................... 3
PREFACE........................................................................................................................................... 4
About this workbook............................................................................................................................................................. 4
Recommended learning material............................................................................................................................................ 4
REST EXERCISES............................................................................................................................... 6
Exercise 01 | Exploring the REST Protocol....................................................................................................................... 6
Exercise 02 | Basic Functions.............................................................................................................................................. 7
Exercise 03 | Creating an Item............................................................................................................................................. 8
Exercise 04 | Verify Items. .................................................................................................................................................... 9
Exercise 05 | Exporting from the API Scan to Tricentis Tosca......................................................................................... 10
Exercise 06 | Adding Business Parameters......................................................................................................................... 11
Exercise 07 | Adding Values................................................................................................................................................ 13
SOAP EXERCISES............................................................................................................................. 15
Exercise 08 | SOAP Scan.................................................................................................................................................... 15
Exercise 09a | Export to Modules and Add Business Parameters.................................................................................... 17
Exercise 09b | Complete the TestCase................................................................................................................................ 19
SELF CREATED SOAP EXERCISE..................................................................................................... 21
Exercise 10 | Self-Created SOAP....................................................................................................................................... 21
XML EXERCISES............................................................................................................................... 24
Exercise 11 | Create XML Modules. .................................................................................................................................. 24
Exercise 12a | Insert Data into an XML File...................................................................................................................... 25
Exercise 12b | Verify Data in an XML File.......................................................................................................................... 26
3
Preface
PREFACE
About this workbook
This workbook is specifically designed to supplement training of the Tricentis Automation Specialist for API.
The workbook is arranged in sections. Each section contains a number of exercises which give detailed instructions on
how to perform it.
Tricentis recommends to complete all exercises before continuing to the next section and to take the related online
exams in order to create high impact learning.
For each exercise there will be a lesson video that explains how to complete the exercise, most exercises will also have a
solution video that walks through how to complete the exercise in full.
This workbook is not aiming to be a complete manual.
4
REST Exercises
5
Rest Exercises
REST EXERCISES
Exercise 01 | Exploring the REST Protocol
Objective
By the end of this exercise, you will be able to explore the REST Protocol using Swagger by simulating the web process, which
usually takes place when a task is executed between a client and a server.
Busness context:
A coffee company has multiple shops. In each shop, a customer can create and delete their own coffee, without being able
to see, alter or delete other customer’s coffees. The default coffees of the shop can be seen, but not altered or deleted. To
achieve this, each customer will need to have a unique key.
Instructions
2. Generate the Service Access Key and keep a note of it. Each key is valid for 24 hours.
Enter the Service User Interface on Swagger by visiting the following address:
3.
http://webservice.toscacloud.com/training/swagger/ui/index
Test the POST function in Swagger:
• Click on Coffees -> POST.
• Paste the key into the key text field.
• Enter a new coffee according to the example value, replacing two “string” values. For example:
4. {
"Name": "Batcoffee",
"Description": "Full of justice."
}
• Click “Try it out!”
Verify whether the coffee has been added by trying out the GET function:
• Click on GET/api/Coffees/{key}
5. • Enter the key obtained in Step 2
• Click “Try it out!”
• Verify if the new coffee is in the Response Body
Hints
»» If you get an error with the message "ExceptionMessage": "Key '{key}' not recognized - Please generate a new key!",
check if the key you entered is correct and whether you have accidentally pasted an empty character along with the
key. This applies to Swagger, the API Scan and Tosca Commander.
6
Exercise 02 | Basic Functions
Objective
By the end of this exercise, you will be able to use the basic functionalities of API Scan.
Key elements:
Component
Project Scan URI
Folder
Instructions
Create a new single-user workspace in Tosca with the standard Subset (click on the Use workspace
1. template checkbox and make sure the path
C:\Tosca_Projects\ToscaCommander\Standard.tce is entered).
2. Go to the Project view by selecting the Home>>Project button on the Home section of Tosca Commander.
3. Right click on the root Folder and create a new Component Folder named "REST Scan".
4. Open the API Scan and start a new, empty project. Name the root project element "Coffeeshop".
Hints
»» Right click on an object (Folder/Operation/Message) to open the context menu.
7
Rest Exercises
Key elements:
Component
Message Request Response Run
Folder
Instructions
1. Duplicate the Folder "Ex 2 Scan REST" and rename the new Folder to "Ex 3 Create Coffee".
Select the Message "Coffees_Post" from /training/api/Coffees/{key}>>Coffees_Post and rename it to "01
2.
Create Coffee".
Select the Params tab next to the Payload tab on the Message Section. Enter the access key retrieved from
3.
Exercise 1 as the Value for "key".
Enter the following data for a coffee into the Payload (without changing the ID) to create a new coffee:
{
4. "Name": "Freezing Coffee",
"Description": "Very cold, let it go."
}
6. Check the Response tab to see if the Status Code is 200 OK.
8
Exercise 04 | Verify Items
Objective
By the end of this exercise, you will be able to verify the result after adding an item to the list.
Instructions
1. Duplicate the Folder "Ex 3 Create Coffee" and rename the new Folder to "Ex 4 Verify Coffee".
3. On the Request part of 02 Verify Coffee, enter the Access Key and press Run.
4. In the Response part, you will see a list of coffees, including the two self-created coffees.
9
Rest Exercises
Key elements:
Component
API TestCase
Folder
Instructions
1. In Tosca Commander, highlight the REST Scan Component Folder created during Exercise 02.
4. Select the following Messages: "01 Create Coffee", "02 Verify Coffee", "03 Delete Coffee".
5. Export the selected Messages to Tosca using the API Test Case button.
In Tosca Commander, rename the newly created Component Folder ApiScan_Import to "Ex 5 Export
6.
Coffeeshop".
7. Move all the TestSteps in all the TestCases created by the API Scan into one TestCase.
01 Create Coffee
01 Create Coffee Response
02 Verify Coffee
Modules
02 Verify Coffee Response
03 Delete Coffee
03 Delete Coffee Response
Ex 5 Export Coffeeshop
01 Create Coffee
01 Create Coffee Response
02 Verify Coffee
TestCases Coffeeshop
02 Verify Coffee Response
03 Delete Coffee
03 Delete Coffee Response
Hints
»» Select multiple Messages in the API Scan by holding down the Ctrl key whilst clicking on them.
»» After exporting the necessary Messages, you can save the scanned Subset and close the API Scan.
10
Exercise 06 | Adding Business Parameters
Objective
By the end of this exercise, you will be able to add Business Parameters to a Module directly from the Payload.
Key elements:
Add Buffer
Instructions
Duplicate the Component Folder "Ex 5 Export Coffeeshop" in Tosca Commander and rename it to "Ex 6
1.
Add Business Parameters".
2. Select the Module "01 Create Coffee".
5. Navigate back to the Payload tab, add the Name and Description Business Parameters.
13. Make sure that your Modules have the following Business Parameters:
11
Rest Exercises
Hints
»» In the API context of testing with Tricentis Tosca, Business Parameters are the Attributes of a Module and are not
similar to the Business Parameters you have been familiarized with from the Reusable TestStepBlocks.
12
Exercise 07 | Adding Values
Objective
By the end of this exercise, you will be able to add Values to TestCases generated from the API Scans, both automatically and
manually.
Business Context:
After adding the Business Parameters for this API TestCase, now is the time to verify that all the functions are correct. This
TestCase verifies whether the coffee was added successfully and then deletes the recently added coffee.
Key elements:
Values
Instructions
1. Duplicate the Component Folder "Ex 6 Add Attributes" and rename it to "Ex 7 Add Values".
2. Select the TestCase "Coffeeshop", add a Test Configuration Parameter called Key.
3. Use the key given as the value for the Test Configuration Parameter.
Focus on the "Coffeeshop" TestCase. Select all the TestSteps inside (make sure that only the TestSteps are
4.
selected) by holding down the Ctrl key while selecting them.
Click on the Auto fill Values button from the Home menu, select "from Default" in Tosca if a drop-down
5.
box appears.
6. Replace all the values of the TestStepValues key with {CP[Key]}.
For the TestStep "02 Verify Coffee Response", enter the data as below, using the name and description
7.
matching the ID of the coffee that you created in the API Scan for Ex 3 Create Coffee.
8. For the "03 Delete Coffee" TestStep, change the value of Id to {B[Id]}.
Hints
»» Replace the value of the TCP key if you use a new key.
»» The value being populated for the TestStepValues key after you click the Values button is the key you entered into
the API Scan.
13
Rest Exercises
SOAP Exercises
14
SOAP EXERCISES
Exercise 08 | SOAP Scan
Objective
By the end of this exercise, you will be able to scan a SOAP API and translate it into a working TestCase.
Business Context:
Create an order of BlueJeans in the DemoWebshop from beginning to end without needing to open the website on a
browser. To do this, the DemoWebShop customer SOAP API will need to be scanned and automated.
Key elements:
Operations Message
Instructions
1. Right click on the project root Folder and create a new Component Folder named SOAP Scan.
Start the API Scan. If there is a project already open in API Scan, click Close, and create a new API Scan
2.
Project.
Select the "01 Get Address" Message. In the Request part, replace the Values of usernameOrEmail and
9.
userPassword with your account credentials.
10. Press the Run button to get the address back.
11. Enter the following Values in the Request Payload for the following Messages and then send them.
15
SOAP Exercises
Hints
»» You should use a DemoWebshop account that has an address (the account for Automation Specialist Level 2, for
example). In case you do not have a DemoWebShop account, create one with an address.
16
Exercise 09a | Export to Modules and Add Business Parameters
Objective
By the end of this exercise, you will be able to export the SOAP Scan and add Parameters.
Business Context:
This is an order for the DemoWebshop. First, Tosca will get the address of the current user and buffer it. BlueJeans will be added to
the cart and then checked out. Tosca will then use the buffered user’s address for shipping and billing. The order will be checked
against a list of orders placed during the current month, using the dynamic date expressions for the start and end dates of the
month, to confirm whether it exists. If it does, the price of items, price with shipping, price with tax, etc. will be verified by Tosca.
As SOAP is a stateless protocol, the server doesn’t retain your data. Therefore, with every single request, you also have to
send your username and password.
Instructions
3. Click on the "API Test Case" button to export them to Tosca Commander.
17
SOAP Exercises
Hints
»» You can select multiple items in the API Scan using the Ctrl key.
»» You can use the Search in Payload function to look for certain Attributes.
18
Exercise 09b | Complete the TestCase
Objective
By the end of this exercise, you will be able to create a complete, executable TestCase.
Instructions
1. Duplicate the Component Folder "Ex 9a SOAP Modules" and rename it "Ex 9b SOAP TestCase".
Create two Test Configuration Parameters in the "Shipping Cost" TestCase, named "User" and "Pass" and
2.
enter your username & password.
Select all the TestSteps (without the TestStepValues or the TestCase) in "Shipping Cost" and click on the
3.
"Auto fill Values" button. If a drop-down menu is shown, select "from Default".
Make sure to enter the Test Configuration Parameters for all usernameOrEmail and Password
5.
TestStepValues.
6. Run the TestCase in the Scratchbook.
Hints
»» Make sure to not select any unnecessary characters when copying the dynamic dates.
»» See the same date Values from the table above copy-pasted below:
{MONTHFIRST[][][yyyy-MM-dd]}T01:00:00
{MONTHLAST[][][yyyy-MM-dd]}T23:59:59
19
SOAP Exercises
20
SELF CREATED SOAP EXERCISE
Exercise 10 | Self-Created SOAP
Objective
By the end of this exercise, you will be able to create and use a SOAP Message without scanning.
Business Context:
In this TestCase, we will delete the order placed in Exercise 09. However, the DemoWebShop Admin API is not yet launched so
the technical code will be entered in the API Scan without needing to scan the API. As soon as the API is launched, we simply
need to add the Endpoint and Resource paths to the already created TestSteps to execute the TestCase. This enables a full
test earlier in the testing cycle.
Key elements:
Headers
Instructions
In Tosca Commander, duplicate the Folder "Ex 9b SOAP TestCase" and rename it "Ex 10 Full Order with
1.
Delete".
2. In the API Scan, duplicate the "Ex 8 SOAP Scan" Folder and rename it "Ex 10 Delete Order".
3. Right click on "Ex 10 Delete Order" Folder and choose "Create Message". Name it "05 Delete Order".
4. Expand the Header in the work area by clicking on the "Headers" button.
21
Self Created Soap Exercise
9. Export the Message into "Ex 10 Full Order with Delete" in Tosca Commander.
Organize the newly created Module "05 Delete Order" and TestStep "05 Delete Order" into the Folders
10.
where the other Modules and TestCases are located. Delete the irrelevant Folders, Module and TestStep.
Add the following Business Parameters for the Module "05 Delete Order": Endpoint, Resource, int,
11.
usernameOrEmail, userPassword.
12. Add the following values to the TestStepValues of TestStep "05 Delete Order":
Name Value
Endpoint http://demowebshop.tricentis.com
Resource /Plugins/Misc.WebServices/Remote/NopService.svc
int {B[OrderID]}
usernameOrEmail {CP[User]}
userPassword {CP[Pass]}
22
XML Exercises
23
XML Exercises
XML EXERCISES
Exercise 11 | Create XML Modules
Objective
By the end of this exercise, you will be able to create an XML Module for the supplied XML file using the API Scan.
Business Context:
A webshop has an XML file that contains all of its products. Users can add a product to the XML file and verify it.
Key elements:
Instructions
1. Download the file "Products.xml" to your computer. You can find it in the Learning Portal.
2. In Tosca Commander, create a new Component Folder and rename the Component Folder to "XML Scan".
Open the API Scan. Rename the project from "New Project" to "Demo Webshop". Delete the empty
3.
Message.
Rename the Folder "Folder" to "Ex 11 Scan XML File". Select this new Folder and choose the "File" button
4.
from the Home menu of Tosca API Scan window to open the XML file "Products.xml".
5. In Tosca Commander, select the "XML Scan" Folder.
In the API Scan window, select the "XML/JSON Test Case" option from the drop-down menu of the API Test
6.
Case button to export the Modules and TestCase.
7. Rename the Folder "ApiScan_Import" to "Ex 11 XML Module". Rename the TestCase to “XML Products“.
Navigate to the Module “Products” in the "Modules" Folder. Expand the attributes of Products, then identify
8
the following attributes and delete the others. Click OK when prompted.
Element Sub-Element
Product ProductId
ProductTypeId
ParentGroupedProductId
VisibleIndividually
Name
ShortDescription
FullDescription
Hints
»» Before deleting the irrelevant nodes, make sure that you don’t select the Products or Product node because it will
result in deleting all subsequent nodes.
24
Exercise 12a | Insert Data into an XML File
Objective
By the end of this exercise, you will be able to add data to an XML file using the API Scan.
Instructions
1. Duplicate the Folder "Ex 11 XML Module" and rename it "Ex 12a Add XML Product" in Tosca Commander.
Hints
»» The new XML file is saved in the file path specified in your computer’s local drive, the file can be opened and
viewed.
»» The full file path can be easily copied when holding the Shift key down while doing a right click on the file and
choosing “copy as path” in Windows Explorer.
25
XML Exercises
Instructions
1. Duplicate the Folder "Ex 12a Add XML Product" and rename it "Ex 12b Verify XML Product".
3 Amend the "Insert Product" TestStep to change the Element Product as per the table below:
Add Module "Products" again in between the steps "Insert Product" and Save XML file. Rename the
4.
TestStep to "Verify Product".
5. Verify the Data that has been inserted into the XML file using the table below:
26