How to work with If-Else logical steps in Test Studio

In this post we will take a look on working with logical steps in Test Studio.

clip_image001

We will understand working with Logical Steps in Test Studio using a Test Scenario. Let us suppose you have a Web Application as following. User will enter numbers in text input and click on the Add Numbers button to get the summation of two numbers. Summation of numbers are displayed in a span.

clip_image002

Now suppose we have a test scenario stated as below,

“If output contains 89 then navigate to Google (or perform any other tasks) else navigate to Bing (or perform other tasks)

We are going to walkthrough, how this could be achieved.

Start recording the test.

Step 1

Navigate to application. In this example test application is on local host and can be accessed at URL http://localhost:55391/demoifelseteststudio.html

Step 2

Enter numbers in both input text boxes

Step 3

Click on the Add Numbers button

Step 4

From docked Test Studio panel, select option of Enable or Disable hover over highlighting

clip_image003

And select output span to put a verification step,

clip_image004

Select the option of Build Verifications. Here create a verification step by clicking on Content then choosing contains from drop down.

clip_image006

Now minimize the browser and go back to Test Studio to verify that all test steps got created as expected or not. Make sure that you are minimizing Test Studio not closing it.

Step 5

In Test Studio you will find all the recorded steps so far,

clip_image008

Now from the ribbon click on Logic and select If-Else

clip_image001[1]

After selecting if-else, you will find two steps has been added. Hover over step contains if statement. You will get a green add button.

clip_image009

Click on the green add button to add a verification step as condition of if statement. Next you will find that a green add button next to the verification step (in this case InnerText Contains 89 of outputspan). Click on the green add button to select that verification. After that you will notice that that verification step has been added as condition of if statement.

clip_image011

Step 6

Maximize the browser in which we were recording the testing steps. And browse to http://www.google.co.in/ . Again minimize the browser and come back to Test Studio.

Step 7

You will find a step has been added.

clip_image013

Drag this step and drop on if condition step.

Step 8

Maximize the browser in which we were recording the testing steps. And browse to http://www.bing.com/ . This time close the browser to stop the recording.

Step 9

You will find a step has been added.

clip_image014

Drag this step and drop on else condition step.

Now you have successfully added if-else logical step in the Test. Go ahead and execute the test and you will find all the test steps has been passed with if statement

clip_image015

If you change verification step form contains to not contains then steps of else condition will get executed.

clip_image017

In this way you can work with if-else logical condition in Test Studio. I hope you find this post useful. Thanks for reading.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s