Вы находитесь на странице: 1из 26



Automation Specialist for API

STUDENT EXERCISE WORKBOOK

1
Survey

SURVEY
Tricentis Automation Specialist for API
Student Exercise Workbook
• Version 2019
• Designed to be used with Tricentis Tosca version 12.x

Student Exercise Workbook


This exercise workbook is designed to provide a collection of exercises on the methods and concepts covered in the
Tricentis Automation Specialist for API training.

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.

© 2019 by 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.

Recommended learning material


In addition to this workbook it is necessary to use the following material to complete the exercises successfully.
Tricentis.Demo.Swagger
This sample application is used for most of the exercises. Please use the link below to start the sample application
http://webservice.toscacloud.com/training/swagger/ui/index

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.

Why is this important?


To gain a full understanding of the REST Protocol.

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

1. Open the Coffeeshop at http://webservice.toscacloud.com/training

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.

Why is this important?


Being able to use the user interface and basic functions of the API Scan tool is essential to being able to scan APIs.

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".

5. Delete the "New Folder" and "Message" elements.

6. Scan the URI: http://webservice.toscacloud.com/training/swagger/docs/v1

7. Rename "Tricentis.Demo.Swagger" Folder to "Ex 2 Scan REST".

Hints
»» Right click on an object (Folder/Operation/Message) to open the context menu.

7
Rest Exercises

Exercise 03 | Creating an Item


Objective
By the end of this exercise, you will be able to interact with the REST service and add items to an existing list using the API
Scan.

Why is this important?


This is the first step necessary for automating API testing.

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."
}

5. Send the Message.

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.

Why is this important?


Retrieving and checking data in a list is an important function in testing.

Instructions

1. Duplicate the Folder "Ex 3 Create Coffee" and rename the new Folder to "Ex 4 Verify Coffee".

2. Rename the Message /training/api/Coffees/{key}>>Coffees_Get>>Coffees_Get to "02 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.

5. Rename the Message /training/api/Coffees/{key}/{id}>>Coffees_Delete>>Coffees_Delete to "03 Delete Coffee".

9
Rest Exercises

Exercise 05 | Exporting from the API Scan to Tricentis Tosca


Objective
By the end of this exercise, you will be able to export the API Scan results to Tosca Commander and verify the correct
creation of Modules and TestCases.

Why is this important?


To be able to build an automated TestCase, the API scan results should be imported into Tosca Commander.

Key elements:

Component
API TestCase
Folder

Instructions

1. In Tosca Commander, highlight the REST Scan Component Folder created during Exercise 02.

2. In the API Scan, duplicate the Folder "Ex 4 Verify Coffee".

3. Rename the new Folder "Ex 5 Export to Tosca".

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.

8. Rename this TestCase "Coffeeshop" and delete the remaining TestCases.

9. Ensure that the artifacts have the following structure:

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.

Why is this important?


This saves manual time in preparing the TestCases. It allows the tester to create many TestCases from the same Module.

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".

3. Navigate to the Technical View tab.

4. Select the Params tab. Add the key Business Parameter.

5. Navigate back to the Payload tab, add the Name and Description Business Parameters.

6. Select the Module "01 Create Coffee Response".

7. Buffer the "ID" Business Parameter.

8. Add Description and Name Business Parameters.

9. Add the key Business Parameter to any remaining Request Module.

10. Select "02 Verify Coffee Response" Module.


Highlight the whole code block of the "Freezing Coffee" you have created earlier in the API Scan, including
11.
the beginning and end curly brackets ({ }) and click the Add button.
12. Select the 03 Delete Coffee Module. Add the StatusCode Business Parameter.

13. Make sure that your Modules have the following Business Parameters:

11
Rest Exercises

01 Create Coffee key


Name
Description
01 Create Coffee Response Id
Name
Description
Ex 6 Add 02 Verify Coffee key
Modules
Attributes
02 Verify Coffee Response item Id
Name
Description
03 Delete Coffee key
id
03 Delete Coffee Response StatusCode

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.

Why is this important?


Automatically adding Values saves time and reduces the possibility of human errors.

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.

Name Value ActionMode DataType


02 Verify Coffee
Response Item Select String

Id {B[Id]} Constraint Numeric


Name Freezing Coffee Verify String
Description Very cold, let it go Verify String

8. For the "03 Delete Coffee" TestStep, change the value of Id to {B[Id]}.

9. Run the TestCase in the Scratchbook.

10. Mark the TestCase WorkState as “COMPLETED”.

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.

Why is this important?


SOAP is one of the most popular Web services. Being able to scan the SOAP API will help with automating most SUTs.

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.

3. Delete the empty new Folder and Message.

Click on the URI Icon and enter the following URI:


4.
http://demowebshop.tricentis.com/Plugins/Misc.WebServicesCustomer/Remote/NopService.svc
Rename the "New Project" root Folder to "DemoWebshop" and the "NopService" Folder to "Ex 8 SOAP
5.
Scan".
6. Rename the Operation "Get Address" to "01 Get Address". The Operation should move to the top.

7. Rename the Message "Get Address" to "01 Get Address".

8. Rename the following Operations and Messages:

Original Name Change to


AddToCart 02 Add To Cart
CreateOrder 03 Create Order
GetOrderCollection 04 Verify Order Placement

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

Message TestStepValue Value


02 Add To Cart sku BlueJeans
quantity 4
usernameOrEmail Enter your username
userPassword Enter your password
03 Create Order paymentMethodName Payments.PurchaseOrder
shippingMethodName Ground
billingAddress & The a:Id given back to you from
shippingAddress 01 Get Address Response.
usernameOrEmail Enter your username
userPassword Enter your password

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.

Why is this important?


To transform the technical information from the API Scan into business relevant Modules in Tosca Commander. This is how
you define the important Parameters that are relevant for your TestCase.

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

1. In Tosca Commander, select the Component Folder "SOAP Scan".


In the API Scan, select the Messages: "01 Get Address", "02 Add To Cart", "03 Create Order", "04 Verify
2.
Order Placement".

3. Click on the "API Test Case" button to export them to Tosca Commander.

4. Rename the newly created "ApiScan_Import" Folder to "Ex 9a SOAP Modules".

5. Rename one of the TestCases to "Shipping Cost".

6. Rearrange the TestSteps into the "Shipping Cost" TestCase as below:

Shipping Cost 01 Get Address


01 Get Address Response
02 Add to Cart
02 Add to Cart Response
03 Create Order
03 Create Order Response
04 Verfiy Order Placement
04 Verify Order Placement Response

7. Add the following Business Parameters to the Modules:

17
SOAP Exercises

Message Attribute Add Type


01 Get Address usernameOrEmail Add
userPassword Add
01 Get Address Response Id Buffer
02 Add to Cart sku Add
quantity Add
usernameOrEmail Add
userPassword Add
03 Create Order paymentMethodName Add
shippingMethodName Add
billingAddress Buffer
shippingAddress Buffer
usernameOrEmail Add
userPassword Add
03 Create Order Response Id Buffer
04 Verify Order Placement startDateValue Add
endDateValue Add
orderStatus Add
paymentStatus Add
shippingStatus Add
pageIndex Add
usernameOrEmail Add
userPassword Add
04 Verify Order Placement WebServiceOrder OrderId Add
Response OrderSubtotalExclTax Add
OrderShippingExclTax Add
OrderTotal Add

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.

Why is this important?


You will be able to steer TestCases created with the API Scan..

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".

4. Expand all the TestSteps to show the TestStepValues.

TestStep Name Value ActionMode DataType


03 Create Order billingAddress {B[Id]} Insert String
shippingAddress {B[Id]} Insert String
03 Create Order Id OrderID Buffer String
Response
04 Verify Order startDateValue {MONTHFIRST[][][yyyy- Insert String
Placement MM-dd]}T01:00:00
endDateValue {MONTHLAST[][][yyyy- Insert String
MM-dd]}T23:59:59
shippingStatus NotYetShipped Insert String
pageIndex 1 Insert String
04 Verify Order WebServiceOrder OrderId {B[OrderID]} Constraint String
Placement OrderSubtotalExclTax 4.0000 Verify Numeric
Response
OrderShippingExclTax 10.0000 Verify Numeric
OrderTotal 14.0000 Verify Numeric

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

Self-Created SOAP Exercise

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.

Why is this important?


Sometimes the TestCases are created before the system is ready to be scanned. This allows the TestCase to be created
earlier and reduce dependency on other development processes.

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.

5. Enter the following information into the fields:

Content-Type text/xml; charset=utf-8


SOAPAction "http://tempuri.org/INopService/DeleteOrders"

Enter the following code into the Payload:

<?xml version="1.0" encoding="utf-8"?>


<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<DeleteOrders xmlns="http://tempuri.org/">
6. <ordersId>
<int xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">293351</int>
</ordersId>
<usernameOrEmail>usernameOrEmail</usernameOrEmail>
<userPassword>userPassword1</userPassword>
</DeleteOrders>
</s:Body>
</s:Envelope>

7. Use Pretty Print to format the code.

8. Set the method to POST.

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]}

13. Run the TestCase in Scratchbook.

14. Mark the TestCase WorkState as “COMPLETED”.

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.

Why is this important?


XML Modules allow Tosca to steer the 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:

Scan File API TestCase

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.

Why is this important?


Inserting Data into an XML file is a common process.

Instructions

1. Duplicate the Folder "Ex 11 XML Module" and rename it "Ex 12a Add XML Product" in Tosca Commander.

2. Rename the TestCase to "Add Product".


Navigate to the TestStep "Products". Delete all but one Product. Expand that Product and delete all the
3.
TestStepValues that show <no Module Attribute associated>.
To complete the TestCase, use the information contained in the table below. Some of the Modules being
4.
used are XML Standard Modules, which are located at Tricentis Standard Modules>>TBox XEngines>>XML.

Module Rename TestStep TestStepValue Value Action Mode


Open/Create XML File Open XML file Resource Products Input
(Standard Modules) Filepath Enter the full file path Input
and file name to the
“Products.xml” file
Products Insert Product Resource Products Select
Products Select
Product Insert
ProductId 634 Insert
ProductTypeId 23 Insert
ParentGroupedProductId 11 Insert
VisibleIndividually True Insert
Name Spice Wars Insert
ShortDescription wall mounted spice Insert
rack
FullDescription country rustic wire Insert
style holds 18 bottles
Save XML file Save XML File Resource Products Input
(Standard Modules) Filepath Enter the path to the Input
Folder containing the
original “Products.
xml” however change
the name of the file to
”ProductsNew.xml”

5. Run the TestCase in the Scratchbook.

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

Exercise 12b | Verify Data in an XML File


Objective
By the end of this exercise, you will be able to verify specific data within an XML file.

Why is this important?


Items within an XML file require verification like any other TestCase. This exercise will demonstrate the process to complete it.

Instructions

1. Duplicate the Folder "Ex 12a Add XML Product" and rename it "Ex 12b Verify XML Product".

2. Rename the TestCase "Add Product" to "Add and Verify Product".

3 Amend the "Insert Product" TestStep to change the Element Product as per the table below:

TestStep TestStepValue/ Element / Subelement Value ActionMode


Insert Product Resource Products Select
Product Insert
ProductId 635 Insert
ProductTypeId 23 Insert
ParentGroupedProductId 11 Insert
VisibleIndividually True Insert
Name Cuddly Wolf Toy Insert
ShortDescription Fluffy Insert
FullDescription Winter is coming Insert

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:

TestStep TestStepValue/ Element / Subelement Value ActionMode


Verify Product Resource Products Select
Products Select
Product Select
ProductId 635 Constraint
ProductTypeId 23 Verify
ParentGroupedProductId 11 Verify
VisibleIndividually True Verify
Name Cuddly Wolf Toy Verify
ShortDescription Fluffy Verify
FullDescription Winter is coming Verify

6. Run the TestCase in the Scratchbook.

26

Вам также может понравиться