The Library Grows…

Missed Part 1? Catch up here!

The library grows and now there are two shelves – science and literature with 3 books each:

 

rsz_xml1

 

 

Since I have only a few books in our library, I will run “get all books” query and get back the content of the library as an XML:

rsz_xml21

 

 

My task now is to check the author of Godel, Escher, Bach with Tosca.

Of course, as before, I can select the second book in the first shelf  and verify that the first property is the correct author by using the #<number> syntax:

XML31

 

 

In this case, the problems with this solution are quite obvious:

  1. It is very hard to read
  2. It will fail if the order of the data is not always the same – the librarian can put the books in a different order

So I need to create a more stable test case.

First of all I don’t have to know in which shelf the librarian has put the book. So I first have to find the correct shelf.

I can do that by selecting the shelf which contains a book with the Title Godel*. This is done by using the following Constraints.

XML41

 

 

Now I have selected the shelf with the book I am searching:

rsz_xml61

 

The XML representation of the shelf content looks like that:

rsz_xml71

 

 

Note: This even works if the librarian has put the book in the second shelf Literature. We are selecting the shelf by its content and not by its name.

Still I need to find the correct book in the shelf – so I have to repeat this step to find this book by using the constraints again:

XML81

 

 

This selects the correct book:

rsz_xml91

 

The book itself has a couple of properties –normally I find them on the cover of the book:

rsz_xml101

 

The XML representation of the book returns all registered properties of it as describedby nodes:

rsz_xml11

 

 

Now I am almost there – the final step is to select the right describedby property and verify the value:

XML12

 

If I want to check also when it was Published I just add:

XML13

 

This looks complicated however, and I want to hide this complexity from users by using reusable test step blocks.

 

The Power of Reusable Test Step Blocks

Let’s start by creating a test step library and drag & drop the XML test step into it, thus creating a reusable test step block (RTB).

XML14

 

 

Now, this would always search the same book so we want to have a more flexible way of adding parameters.

Right-click on the RTB (in our case it is called library) and select Create->Input Parameters.

XML15

 

 

You can now create parameters for your RTB:

XML16

 

 

I have created three parameters and grouped them by Search and Verify to make it easier to use them later:

XML17

 

 

The next step is to replace the actual values by the parameters. The syntax is: {PL[<parameter name>]}

Note: PL stands for Parameter Link.

XML18

 

 

You can also use drag & drop to set the parameters.

Now that I have prepared the test step block I can use it in my test case:

XML19

 

 

I already added a second step in which I search for Robinson Crusoe – I could also use TCD (test case design).

If you want to see the full content of the test step – press F11 or click on the small icon in the lower right corner.

XML20

 

 

I can now check the actual value:

XML23

 

 

Pressing F11 again will hide the details again.

As you can see we have now created a very flexible way handling XML data and I have even hidden the complexity from the user!

Stayed tuned for How to Verify Complex XML Structures: Part 3!

Part 1: The Library
Part 3: What About Xpath?

 

Want to know more? Watch our free webinar, “Web Service Test Automation 101” with Georg Thurner.

 

Watch the Webinar

Accelerate 2017 is October 16-17 - learn more

LEARN MORE
X