Skip to content
rahuldantalwal edited this page Apr 27, 2016 · 1 revision

Reusable Test Case

In JabongGenericAutomationframework when we have a step or number of steps to be executed many times then we can use that as Reusable test case.

@R is used for Reusable test case.

We can use the reusable test case as - @R Test_suite_name:Test_case_name;

Every flow for any page can have different test case and that can be used as Reusable test case. We can improve the quality of a single test case by adding Reusable test cases into them.

One Reusable test case can have multiple reusable test cases.

How To Write Reuseable Test Cases

Lets take a Jabong Login scenario

Create Automation testcase For given login Manual Steps:-  

Step 1 HOME:LAUNCH_APPLICATION
Step 2 LOGIN:OPEN_LOGIN_FORM
Step 3 LOGIN:ENTER_LOGIN_USER_DETAILS
Step 4 LOGIN:VERIFY_USER_LOGIN_SUCCESSFULLY

Lets take TestSuite name: LOGIN

Page require for login functionality:- HOME, LOGIN

HOME: LAUNCH_APPLICATION

LAUNCH_APPLICATION
HOMEPAGE USER @A INITIALIZE; THE APPLICATION

LOGIN: OPEN_LOGIN_FORM, VERIFY_USER_LOGIN_SUCCESSFULLY, ENTER_LOGIN_USER_DETAILS

OPEN_LOGIN_FORM
LOGIN VERIFY THAT @O LOGINLINK; @A OBJECT IS THERE; @S CRITICAL;
AND @A CLICK ; ON @O LOGINLINK;
ENTER_LOGIN_USER_DETAILS
LOGIN AND @A ENTER; THE EMAIL-ID IN @O TXTUSERNAMEONLOGINPOPUP;
AND @A ENTER; THE PASSWORD IN @O TXTPASSWORDONLOGINPOPUP;
AND @A SUBMIT; THE CREDENTIALS ON @O BTNSIGNINONLOGINPOPUP;

Username and password details are -

TXTUSERNAMEONLOGINPOPUP TXTPASSWORDONLOGINPOPUP
LOGIN USERNAME1 PASSWORD1
USERNAME2 PASSWORD2
USERNAME3 PASSWORD3

We can also use iteration with Reusable test case. We have 3 rows in this table.

We can select the data from indexing. If we have "n" number of rows, indexing starts from 0 to (n-1). It will get 0 index value by default. Indexing used for any step is -

@I {row}; - is used for Iteration @I {0}; - is used for Iteration with first row

VERIFY_USER_LOGIN_SUCCESSFULLY
LOGIN @A IS OBJECT PRESENT; @O WELCOMEUSERLABEL; TO CHECK THE LOGIN MESSAGE

TestCase: VALIDATE_LOGIN_FUNCTIONALITY

VALIDATE_LOGIN_FUNCTIONALITY
@R HOME:LAUNCH_APPLICATION;
OPEN LOGIN PAGE BY INVOKE @R LOGIN:OPEN_LOGIN_FORM;
@R LOGIN:ENTER_LOGIN_USER_DETAILS; @I{2};
@R LOGIN:VERIFY_USER_LOGIN_SUCCESSFULLY;