Tuesday 20 March 2012

QTP – Descriptive Programing – Examples

Leave a Comment

QTP – Descriptive Programing – Examples

OneTestingCenter @ QTP @ Descriptive Programming @ Start up Script


‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
‘ QTP – Descriptive Programing – Examples
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

'Browser("MyBrowser").Page("MyPage").WebEdit("MySearchBox").Set "GAReddy"
'Browser("MyBrowser").Page("MyPage").WebButton("btnG").Click
'wait(5)

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' Descriptive Programing - without OR
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' Google App - Example
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").Set "GAReddy"
Browser("name:=.*").Page("title:=.*").WebButton("name:=btnG").Click
Wait(4)
Browser("name:=.*").CloseAllTabs

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' Gmail App - Example
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Set oPage=Browser("name:=.*").page("title:=.*")
oPage.WebEdit("name:=Email").Set "GAReddy"
oPage.WebEdit("name:=passwd").Set "GAReddy"
oPage.WebButton("name:=Sign In").Click
wait(5)

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' Yahoo App - Example
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Set YahooApp=Browser("name:=.*").Page("title:=.*")

YahooApp.WebEdit("name:=login").Set "ONETESTINGCENTER"
YahooApp.WebEdit("name:=passwd").Set "ONETESTINGCENTER"
YahooApp.WebButton("name:=Sign in").Click
wait(5)

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Set oPage=Browser("name:=.*","CreationTime:=0").page("title:=.*")
oPage.WebEdit("name:=Email").Set "GAReddy"
oPage.WebEdit("name:=passwd").Set "GAReddy"
oPage.WebButton("name:=Sign In").Click
wait(5)

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Read More...

QTP – Descriptive Programing – Any Web App - Working with Web Check Boxes

Leave a Comment
QTP – Descriptive Programing – Any Web App - Working with Web Check Boxes


OneTestingCenter @ QTP @ Descriptive Programming @ Web Check Boxes @ DP Script

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Any Web App – Working with Web Check Boxes
‘ QTP – Descriptive Programing – Working with Web Check Boxes
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Set oWebCheckBox=Description.Create()
oWebCheckBox("micClass").value="WebCheckBox"

Set oPage=Browser("name:=.*").Page("title:=.*")

Set oWebCheckBoxAll=oPage.ChildObjects(oWebCheckBox)
MsgBox "Total Number of Check Boxes on the page are " &vbtab & oWebCheckBoxAll.Count

For i= 0 to oWebCheckBoxAll.Count-1
msgBox "Check Box Name" &vbtab & i &vbtab & oWebCheckBoxAll(i).GetROProperty("value")
' oWebCheckBoxAll(i).Set "ON"
oWebCheckBoxAll(i).Set "OFF"
wait(2)
Next



Set oPage=Browser("name:=.*").Page("title:=.*")
oPage.WebCheckBox("value:=Technology,10,").Set "ON"
'oPage.WebCheckBox("value:="& WebCheckBoxName).Set "ON"

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
‘ Any Web App – Working with Web Check Boxes
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Read More...

QTP - Descriptive Programming - Any Web App - Working with Web List-boxes

Leave a Comment

QTP - Descriptive Programming - Any Web App - Working with Web List-boxes
 
OneTestingCenter @ QTP @ Descriptive Programming @ Working with Web Lists


'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'Any Web App - Working with any list box
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Set oPage=Browser("name:=.*").Page("title:=.*")

Set oWebList=Description.Create()
oWebList("micClass").Value="WebList"
oWebList("Html Tag").Value="Select"
'oWebList("Index").Value="0"

Set AllWebList=oPage.ChildObjects(oWebList)

MsgBox "AllWebList" & vbtab & AllWebList.Count


For i= 0 to AllWebList.Count-1
MsgBox AllWebList(i).GetROProperty("name")
WebListItemsCount=oPage.WebList("Index:=0").GetROProperty("Items Count")
MsgBox WebListItemsCount
Next


For i= 0 to WebListItemsCount-1
oPage.WebList("Index:=0").Select(i)
' wait(2)
If oPage.WebList("Index:=1").Exist(5) Then
SecondListItemsCount=oPage.WebList("Index:=1").GetROProperty("Items Count")
For j=0 to SecondListItemsCount-1
oPage.webList("Index:=1").Select(j)
          Next
End If
Next

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'Any Web App - Working with any list box
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Read More...

QTP - Descriptive Programming - Broken Link Checking

Leave a Comment


QTP - Descriptive Programming - Broken Link Checking
OneTestingCenter @ QTP @ Descriptive Programming @ Broken Link Checking

' @@@@@@@@@@@@@@@@@@@@@@@@@@@@
' QTP – DP - Broken Link Checker tool for Any Web App
‘ Broken Link Check – Descriptive Programing
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@

On Error Resume Next

Set oPage=Browser("name:=.*").Page("title:=.*")

DataTable.AddSheet "dtLinkName"
DataTable.GetSheet("dtLinkName").AddParameter "LinkName",""
DataTable.GetSheet("dtLinkName").AddParameter "PageTitle",""

Set oLink=Description.Create()
oLink("micClass").value="Link"

Set AllLinks=oPage.ChildObjects(oLink)
PageTitle=oPage.GetROProperty("title")
MsgBox "Total Number of links on the page: " &vbtab & PageTitle &vbtab & AllLinks.Count

For i= 0 to AllLinks.Count-1
DataTable.GetSheet("dtLinkName").SetCurrentRow(i+1)
DataTable.Value("LinkName","dtLinkName")=AllLinks(i).GetROProperty("name")
Next


RC=DataTable.GetSheet("dtLinkName").GetRowCount
For i= 1 to RC
DataTable.GetSheet("dtLinkName").SetCurrentRow(i)
LinkName=DataTable.Value("LinkName","dtLinkName")
oPage.Link("name:="& LinkName).Click
wait(2)
MyPageTitle=oPage.GetROProperty("title")
' msgBox MyPageTitle
DataTable.Value("PageTitle","dtLinkName")=MyPageTitle
If MyPageTitle<>"404 Error Page" or MyPageTitle<>"500 Internal Server Error" or MyPageTitle<>"Page Can't be found"  and MyPageTitle=DataTable.Value() Then
Reporter.ReportEvent micPass, "Link works good", "Clicked on Link" & LinKName
Else
Reporter.ReportEvent micFail, "Link does not work good", "Link is BROKEN " & LinKName
End If
Browser("name:=.*").Back
' SystemUtil.Run AppURL
Wait(3)
Next

Read More...

Tuesday 20 March 2012

QTP – Descriptive Programing – Examples


QTP – Descriptive Programing – Examples

OneTestingCenter @ QTP @ Descriptive Programming @ Start up Script


‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
‘ QTP – Descriptive Programing – Examples
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

'Browser("MyBrowser").Page("MyPage").WebEdit("MySearchBox").Set "GAReddy"
'Browser("MyBrowser").Page("MyPage").WebButton("btnG").Click
'wait(5)

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' Descriptive Programing - without OR
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' Google App - Example
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").Set "GAReddy"
Browser("name:=.*").Page("title:=.*").WebButton("name:=btnG").Click
Wait(4)
Browser("name:=.*").CloseAllTabs

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' Gmail App - Example
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Set oPage=Browser("name:=.*").page("title:=.*")
oPage.WebEdit("name:=Email").Set "GAReddy"
oPage.WebEdit("name:=passwd").Set "GAReddy"
oPage.WebButton("name:=Sign In").Click
wait(5)

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' Yahoo App - Example
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Set YahooApp=Browser("name:=.*").Page("title:=.*")

YahooApp.WebEdit("name:=login").Set "ONETESTINGCENTER"
YahooApp.WebEdit("name:=passwd").Set "ONETESTINGCENTER"
YahooApp.WebButton("name:=Sign in").Click
wait(5)

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Set oPage=Browser("name:=.*","CreationTime:=0").page("title:=.*")
oPage.WebEdit("name:=Email").Set "GAReddy"
oPage.WebEdit("name:=passwd").Set "GAReddy"
oPage.WebButton("name:=Sign In").Click
wait(5)

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

QTP – Descriptive Programing – Any Web App - Working with Web Check Boxes

QTP – Descriptive Programing – Any Web App - Working with Web Check Boxes


OneTestingCenter @ QTP @ Descriptive Programming @ Web Check Boxes @ DP Script

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Any Web App – Working with Web Check Boxes
‘ QTP – Descriptive Programing – Working with Web Check Boxes
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Set oWebCheckBox=Description.Create()
oWebCheckBox("micClass").value="WebCheckBox"

Set oPage=Browser("name:=.*").Page("title:=.*")

Set oWebCheckBoxAll=oPage.ChildObjects(oWebCheckBox)
MsgBox "Total Number of Check Boxes on the page are " &vbtab & oWebCheckBoxAll.Count

For i= 0 to oWebCheckBoxAll.Count-1
msgBox "Check Box Name" &vbtab & i &vbtab & oWebCheckBoxAll(i).GetROProperty("value")
' oWebCheckBoxAll(i).Set "ON"
oWebCheckBoxAll(i).Set "OFF"
wait(2)
Next



Set oPage=Browser("name:=.*").Page("title:=.*")
oPage.WebCheckBox("value:=Technology,10,").Set "ON"
'oPage.WebCheckBox("value:="& WebCheckBoxName).Set "ON"

‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
‘ Any Web App – Working with Web Check Boxes
‘@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

QTP - Descriptive Programming - Any Web App - Working with Web List-boxes


QTP - Descriptive Programming - Any Web App - Working with Web List-boxes
 
OneTestingCenter @ QTP @ Descriptive Programming @ Working with Web Lists


'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'Any Web App - Working with any list box
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Set oPage=Browser("name:=.*").Page("title:=.*")

Set oWebList=Description.Create()
oWebList("micClass").Value="WebList"
oWebList("Html Tag").Value="Select"
'oWebList("Index").Value="0"

Set AllWebList=oPage.ChildObjects(oWebList)

MsgBox "AllWebList" & vbtab & AllWebList.Count


For i= 0 to AllWebList.Count-1
MsgBox AllWebList(i).GetROProperty("name")
WebListItemsCount=oPage.WebList("Index:=0").GetROProperty("Items Count")
MsgBox WebListItemsCount
Next


For i= 0 to WebListItemsCount-1
oPage.WebList("Index:=0").Select(i)
' wait(2)
If oPage.WebList("Index:=1").Exist(5) Then
SecondListItemsCount=oPage.WebList("Index:=1").GetROProperty("Items Count")
For j=0 to SecondListItemsCount-1
oPage.webList("Index:=1").Select(j)
          Next
End If
Next

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'Any Web App - Working with any list box
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

QTP - Descriptive Programming - Broken Link Checking



QTP - Descriptive Programming - Broken Link Checking
OneTestingCenter @ QTP @ Descriptive Programming @ Broken Link Checking

' @@@@@@@@@@@@@@@@@@@@@@@@@@@@
' QTP – DP - Broken Link Checker tool for Any Web App
‘ Broken Link Check – Descriptive Programing
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@

On Error Resume Next

Set oPage=Browser("name:=.*").Page("title:=.*")

DataTable.AddSheet "dtLinkName"
DataTable.GetSheet("dtLinkName").AddParameter "LinkName",""
DataTable.GetSheet("dtLinkName").AddParameter "PageTitle",""

Set oLink=Description.Create()
oLink("micClass").value="Link"

Set AllLinks=oPage.ChildObjects(oLink)
PageTitle=oPage.GetROProperty("title")
MsgBox "Total Number of links on the page: " &vbtab & PageTitle &vbtab & AllLinks.Count

For i= 0 to AllLinks.Count-1
DataTable.GetSheet("dtLinkName").SetCurrentRow(i+1)
DataTable.Value("LinkName","dtLinkName")=AllLinks(i).GetROProperty("name")
Next


RC=DataTable.GetSheet("dtLinkName").GetRowCount
For i= 1 to RC
DataTable.GetSheet("dtLinkName").SetCurrentRow(i)
LinkName=DataTable.Value("LinkName","dtLinkName")
oPage.Link("name:="& LinkName).Click
wait(2)
MyPageTitle=oPage.GetROProperty("title")
' msgBox MyPageTitle
DataTable.Value("PageTitle","dtLinkName")=MyPageTitle
If MyPageTitle<>"404 Error Page" or MyPageTitle<>"500 Internal Server Error" or MyPageTitle<>"Page Can't be found"  and MyPageTitle=DataTable.Value() Then
Reporter.ReportEvent micPass, "Link works good", "Clicked on Link" & LinKName
Else
Reporter.ReportEvent micFail, "Link does not work good", "Link is BROKEN " & LinKName
End If
Browser("name:=.*").Back
' SystemUtil.Run AppURL
Wait(3)
Next