KeyWord Driven Framework Using UFT
Objective : To reduce manual efforts in smoke and regression testing.
When ever new deployment is done in QA or Staging
environment, we have to perform shakedown to make sure all the
major and basic functionality of the application are working as
expected and regression testing to make sure that the unchanged
areas of the application under test are working fine. If we are
doing it manually then It is a time consuming or tedious process.
To overcome this, a hybrid framework has been designed using
UFT tool which will perform the shakedown and regression testing
automatically.
Tool Used : UFT (Unified Functional Testing)
Application Under Test : Flight Reservation (Dummy Application)
Script: VB Script
Folder Structure:
Flight_Reservation
----------------------------
Keyword Driven Framework consists of
1. TestData.xls : Key words to be retrieved from “TestData.xls”. We have also kept test data to be used in the application under test.
2. Flight Reservation Test: This is driver script to fetch key words and test data from “TestData.xls”
'================================== Flight Reservation ==================================================
' Close all the excel files
SystemUtil.CloseProcessByName("EXCEL.exe")
'Close all the browsers
SystemUtil.CloseProcessByName("iexplore.exe")
'Create Excel Application object
Set ObjExcel = CreateObject("Excel.Application")
ObjExcel.Workbooks.Open Environment.Value("v_st_TestData_Path")
Set ObjSheet = ObjExcel.ActiveWorkbook.Worksheets("TestData")
row = ObjSheet.UsedRange.Rows.Count
col = ObjSheet.UsedRange.Columns.Count
status = "Pass"
For i = 2 To row Step 1
If ObjSheet.Cells(i,1).Value = EMPTY Then
If Strcomp(Trim(ObjSheet.Cells(i,2).Value),"GOTOURL") = 0 Then
Set IE = Nothing
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
wait 5
IE.Navigate Trim(ObjSheet.Cells(i,5).Value)
'Maximize the browser window
Window("hwnd:=" & IE.HWND).Maximize
Else
status = UIOperation(Trim(ObjSheet.Cells(i,2).Value),Trim(ObjSheet.Cells(i,3).Value),Trim(ObjSheet.Cells(i,4).Value),Trim(ObjSheet.Cells(i,5).Value))
End If
If ObjSheet.Cells(i,5).Value = EMPTY Then
print ObjSheet.Cells(i,2).Value&"----"&ObjSheet.Cells(i,3).Value&"----"&ObjSheet.Cells(i,4).Value&"----"&status
Else
print ObjSheet.Cells(i,2).Value&"----"&ObjSheet.Cells(i,3).Value&"----"&ObjSheet.Cells(i,4).Value&"----"&ObjSheet.Cells(i,5).Value&"----"&status
End If
Else
print vbnewline
print "New Testcase : "&ObjSheet.Cells(i,1).Value&" started"
print vbnewline
End If
Next
ObjExcel.ActiveWorkbook.Close
ObjExcel.Application.Quit
'Release the allocated objects
Set ObjSheet = Nothing
Set ObjExcel = Nothing
3. FR_FunctionLibrary: Function to do UI Operation has been written in this.
Function UIOperation(Action,ObjectName,ObjectType,Value)
status = "Pass"
Browser("creationtime:=0").Page("title:=.*").Sync
ObjectType = Replace(ObjectType,".0","|")
ObjectType = Replace(ObjectType,".5"," ")
a = Split(ObjectType,"|")
Set oDesc = Nothing
Set oDesc = Description.Create
oDesc("micClass").Value = a(0)
For Iterator = 2 To 4 Step 2
Select Case a(Iterator-1)
Case "name"
oDesc("name").Value = a(Iterator)
Case "html id"
oDesc("name").Value = a(Iterator)
Case "abs_x"
oDesc("abs_x").Value = a(Iterator)
Case "abs_y"
oDesc("abs_y").Value = a(Iterator)
Case ""
Case Else
status = "Fail"
print "Wrong Operation Type:"&a(Iterator-1)
End Select
Next
Set colObject = Nothing
Set colObject = Browser("creationtime:=0").Page("title:=.*").ChildObjects(oDesc)
If colObject.Count > 0 Then
Select Case Action
Case "SETTEXT"
colObject(0).Set(Value)
Case "CLICK"
colObject(0).Click
Case "SELECT"
colObject(0).Select(Value)
Case "PROPERTYCHECK"
data = Split(Value,"|")
exp_val = colObject(0).GetRoProperty(data(0))
act_val = data(1)
If StrComp(exp_val,act_val) <> 0 Then
status = "Fail"
End If
Case Else
status = "Fail"
print "Wrong Action : "&Operation
End Select
Else
status = "Fail"
print "Object Not Found : "&a(0)&"----"&a(1)&"----"&a(2)&"----"&a(3)&"----"&a(4)
End If
If Strcomp(status,"Fail") = 0 Then
UIOperation = "Fail"
Else
UIOperation = "Pass"
End If
End Function
Test Execution Report :
New Testcase : Login to Flight Reservation started
GOTOURL------------http://newtours.demoaut.com/----Pass
SETTEXT----UserName----WebEdit.0name.0userName.0.0----mercury----Pass
SETTEXT----Password----WebEdit.0name.0password.0.0----mercury----Pass
CLICK----SignIn----Image.0name.0login.0.0----Pass
When ever new deployment is done in QA or Staging
environment, we have to perform shakedown to make sure all the
major and basic functionality of the application are working as
expected and regression testing to make sure that the unchanged
areas of the application under test are working fine. If we are
doing it manually then It is a time consuming or tedious process.
To overcome this, a hybrid framework has been designed using
UFT tool which will perform the shakedown and regression testing
automatically.
Tool Used : UFT (Unified Functional Testing)
Application Under Test : Flight Reservation (Dummy Application)
Script: VB Script
Folder Structure:
Flight_Reservation
----------------------------
- Function_Libraries
- TestData
- Images
- Repository
- Test Script
Keyword Driven Framework consists of
1. TestData.xls : Key words to be retrieved from “TestData.xls”. We have also kept test data to be used in the application under test.
'================================== Flight Reservation ==================================================
' Close all the excel files
SystemUtil.CloseProcessByName("EXCEL.exe")
'Close all the browsers
SystemUtil.CloseProcessByName("iexplore.exe")
'Create Excel Application object
Set ObjExcel = CreateObject("Excel.Application")
ObjExcel.Workbooks.Open Environment.Value("v_st_TestData_Path")
Set ObjSheet = ObjExcel.ActiveWorkbook.Worksheets("TestData")
row = ObjSheet.UsedRange.Rows.Count
col = ObjSheet.UsedRange.Columns.Count
status = "Pass"
For i = 2 To row Step 1
If ObjSheet.Cells(i,1).Value = EMPTY Then
If Strcomp(Trim(ObjSheet.Cells(i,2).Value),"GOTOURL") = 0 Then
Set IE = Nothing
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
wait 5
IE.Navigate Trim(ObjSheet.Cells(i,5).Value)
'Maximize the browser window
Window("hwnd:=" & IE.HWND).Maximize
Else
status = UIOperation(Trim(ObjSheet.Cells(i,2).Value),Trim(ObjSheet.Cells(i,3).Value),Trim(ObjSheet.Cells(i,4).Value),Trim(ObjSheet.Cells(i,5).Value))
End If
If ObjSheet.Cells(i,5).Value = EMPTY Then
print ObjSheet.Cells(i,2).Value&"----"&ObjSheet.Cells(i,3).Value&"----"&ObjSheet.Cells(i,4).Value&"----"&status
Else
print ObjSheet.Cells(i,2).Value&"----"&ObjSheet.Cells(i,3).Value&"----"&ObjSheet.Cells(i,4).Value&"----"&ObjSheet.Cells(i,5).Value&"----"&status
End If
Else
print vbnewline
print "New Testcase : "&ObjSheet.Cells(i,1).Value&" started"
print vbnewline
End If
Next
ObjExcel.ActiveWorkbook.Close
ObjExcel.Application.Quit
'Release the allocated objects
Set ObjSheet = Nothing
Set ObjExcel = Nothing
3. FR_FunctionLibrary: Function to do UI Operation has been written in this.
Function UIOperation(Action,ObjectName,ObjectType,Value)
status = "Pass"
Browser("creationtime:=0").Page("title:=.*").Sync
ObjectType = Replace(ObjectType,".0","|")
ObjectType = Replace(ObjectType,".5"," ")
a = Split(ObjectType,"|")
Set oDesc = Nothing
Set oDesc = Description.Create
oDesc("micClass").Value = a(0)
For Iterator = 2 To 4 Step 2
Select Case a(Iterator-1)
Case "name"
oDesc("name").Value = a(Iterator)
Case "html id"
oDesc("name").Value = a(Iterator)
Case "abs_x"
oDesc("abs_x").Value = a(Iterator)
Case "abs_y"
oDesc("abs_y").Value = a(Iterator)
Case ""
Case Else
status = "Fail"
print "Wrong Operation Type:"&a(Iterator-1)
End Select
Next
Set colObject = Nothing
Set colObject = Browser("creationtime:=0").Page("title:=.*").ChildObjects(oDesc)
If colObject.Count > 0 Then
Select Case Action
Case "SETTEXT"
colObject(0).Set(Value)
Case "CLICK"
colObject(0).Click
Case "SELECT"
colObject(0).Select(Value)
Case "PROPERTYCHECK"
data = Split(Value,"|")
exp_val = colObject(0).GetRoProperty(data(0))
act_val = data(1)
If StrComp(exp_val,act_val) <> 0 Then
status = "Fail"
End If
Case Else
status = "Fail"
print "Wrong Action : "&Operation
End Select
Else
status = "Fail"
print "Object Not Found : "&a(0)&"----"&a(1)&"----"&a(2)&"----"&a(3)&"----"&a(4)
End If
If Strcomp(status,"Fail") = 0 Then
UIOperation = "Fail"
Else
UIOperation = "Pass"
End If
End Function
Test Execution Report :
New Testcase : Login to Flight Reservation started
GOTOURL------------http://newtours.demoaut.com/----Pass
SETTEXT----UserName----WebEdit.0name.0userName.0.0----mercury----Pass
SETTEXT----Password----WebEdit.0name.0password.0.0----mercury----Pass
CLICK----SignIn----Image.0name.0login.0.0----Pass
New Testcase : Book A Ticket started
SELECT----Departing_From----WebList.0name.0fromPort.0.0----London----Pass
SELECT----Arriving_In----WebList.0name.0toPort.0.0----Frankfurt----Pass
SELECT----Airline_Preference----WebList.0name.0airline.0.0----Blue Skies Airlines----Pass
CLICK----FindFlights----Image.0name.0findFlights.0.0----Pass
CLICK----Continue----Image.0name.0reserveFlights.0.0----Pass
SETTEXT----FirstName----WebEdit.0name.0passFirst0.0.0----Rajendra----Pass
SETTEXT----LastName----WebEdit.0name.0passLast0.0.0----Mahapatra----Pass
SETTEXT----CREDITCARDNUMBER ----WebEdit.0name.0creditnumber.0.0----8763475234----Pass
CLICK----SECURE_PURCHASE----Image.0name.0buyFlights.0.0----Pass
PROPERTYCHECK----BOOKING_CONFIRMATION----WebElement.0abs_x.0138.0abs_y.0273----innertext|Your itinerary has been booked!----Pass
Comments
Post a Comment