Web Scripts

 Web Testing Using QTP
----------------------------------------------------------------------------
'Count Total Objects from Google Home Page and return Class wise Objects count
Dim oObject, Objects
Set oObject=Description.Create()
Set Objects=Browser("title:=Google").Page("title:=Google").ChildObjects(oObject)
TotObjects=Objects.Count
Msgbox TotObjects
Links=0
EditBoxes=0
WebElements=0
Buttons=0
Others=0
Images=0

For i= 0 to TotObjects-1 Step 1
myObject=Objects(i).GetRoProperty("micclass")
'Msgbox myObject

If  myObject= "Link" Then
        Links=Links+1

        ElseIf myObject="WebEdit" Then
     EditBoxes=EditBoxes+1

        ElseIf myObject="WebElement" Then
     WebElements=WebElements+1

         ElseIf myObject="WebButton" Then
     Buttons=Buttons+1

     ElseIf myObject="Image" Then
     Images=Images+1
         Else
         Others=Others+1
End If
Next

Msgbox "Total Links: "&Links
Msgbox "Total Buttons: "&Buttons
Msgbox "Total Elements: "&WebElements
Msgbox "Images: "&Images
Msgbox "Total Edit Boxes: "&EditBoxes
Msgbox "Others: "&Others

Msgbox Links+Buttons+WebElements+Images+EditBoxes+Others
--------------------------------------------------------------------
'Count Total Objects from Flight Reservation Window and return Class wise Objects count
Dim oObject, Objects
Set oObject=Description.Create()
Set Objects=Window("text:=Flight Reservation").ChildObjects(oObject)
TotObjects=Objects.Count
Msgbox TotObjects
EditBoxes=0
RadioButtons=0
Buttons=0
Others=0
ComboBoxes=0
ListBoxes=0

For i= 0 to TotObjects-1 Step 1
myObject=Objects(i).GetRoProperty("Class Name")
'Msgbox myObject

If  myObject= "WinList" Then
        ListBoxes=ListBoxes+1

        ElseIf myObject="WinEdit" Then
     EditBoxes=EditBoxes+1

        ElseIf myObject="WinRadioButton" Then
    RadioButtons=RadioButtons+1

         ElseIf myObject="WinButton" Then
     Buttons=Buttons+1

     ElseIf myObject="WinComboBox" Then
     ComboBoxes=ComboBoxes+1
         Else
         Others=Others+1
End If
Next

Msgbox "Total List Boxes: "&ListBoxes
Msgbox "Total Buttons: "&Buttons
Msgbox "Total RadioButtons: "&RadioButtons
Msgbox "ComboBoxes: "&ComboBoxes
Msgbox "Total Edit Boxes: "&EditBoxes
Msgbox "Others: "& Others

Msgbox ListBoxes+Buttons+RadioButtons+ComboBoxes+EditBoxes+Others

------------------------------------------------------------------------------

‘Verify the Application Launching Operation

SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "http://www.dealsdirect.com.au/"
Wait 8
Browser_Name = Browser("Online Shopping | Australia").GetROProperty("title")

If  Browser_Name = "Online Shopping | Australia Online Shopping | Deals Direct" Then
        Result="Application Launched Successfully"
Msgbox Result
        Else
Result="Application Not Launched "
Msgbox Result
End If

Method 2:
---------
SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "http://www.dealsdirect.com.au/"

If  Browser("Online Shopping | Australia").Exist (10) Then
        Result="Application Launched Successfully"
Msgbox Result
        Else
Result="Application Not Launched "
Msgbox Result
End If

'Verify Customer Registration in www.dealsdirect.com.au  Web Portal

SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "http://www.dealsdirect.com.au/"

Browser("Online Shopping | Australia").Page("Online Shopping | Australia").Link("Register").Click
Browser("Online Shopping | Australia").Page("DealsDirect.com.au Secure").WebEdit("cEmail2").Set "hyderabad123b@gmail.com"
Browser("Online Shopping | Australia").Page("DealsDirect.com.au Secure").WebEdit("cEmail3").Set "hyderabad123b@gmail.com"
Browser("Online Shopping | Australia").Page("DealsDirect.com.au Secure").WebEdit("cPass2").SetSecure "4e6d76187221a6b2585d672f1be203f7ef777f20e255"
Browser("Online Shopping | Australia").Page("DealsDirect.com.au Secure").Image("image-register-and-continue-bu").Click 204,19

If Browser("Online Shopping | Australia").Dialog("Security Alert").Exist(3) Then
Browser("Online Shopping | Australia").Dialog("Security Alert").WinButton("Yes").Click
End If

Message = Browser("Online Shopping | Australia").Page("Your Shopping Cart - DealsDire").WebElement("Welcome Back").GetROProperty("innertext")

If Message = "Welcome Back " Then
        Res="Customer Registerd Successfully"
        Msgbox Res
        Else
Res="Registration Failed"
        Msgbox Res
End If



'Verify Login Operation in www.dealsdirect.com.au Web Portal


SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "http://www.dealsdirect.com.au/"

Browser("DealsDirect.com.au Secure").Page("DealsDirect.com.au Secure").Link("Login").Click
Browser("DealsDirect.com.au Secure").Page("DealsDirect.com.au Secure_2").WebEdit("cEmail1").Set "hyderabad123@gmail.com"
Browser("DealsDirect.com.au Secure").Page("DealsDirect.com.au Secure_2").WebEdit("cPass1").SetSecure "4e6d78c21597a67d10442192132f29f589ade0eb9021"
Browser("DealsDirect.com.au Secure").Page("DealsDirect.com.au Secure_2").Image("image-login-and-continue-butto").Click 151,17
'Browser("DealsDirect.com.au Secure").Dialog("AutoComplete").WinCheckBox("Don't offer to remember").Set "ON"
'Browser("DealsDirect.com.au Secure").Dialog("AutoComplete").WinButton("Yes").Click

If Browser("DealsDirect.com.au Secure").Page("Online Shopping | Australia").Link("Logout").Exist(10) Then
Res="Login Successful"
Else
Res ="Login Failed"
End If
Msgbox Res


'Verify Login and LogOut Links in www.dealsdirect.com.au Web Portal

'Before Login Login Link only Exists, After Login Logout Link only exists

SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "http://www.dealsdirect.com.au/"

If Browser("DealsDirect.com.au Secure").Page("DealsDirect.com.au Secure").Link("Login").Exist Then
        If Not  Browser("title:=DealsDirect.com.au Secure").Page("title:=DealsDirect.com.au Secure").Link("text:=Logout").Exist(5) Then
        Msgbox "Login Link Only Exists"
                End If
End If

Browser("DealsDirect.com.au Secure").Page("DealsDirect.com.au Secure").Link("Login").Click
Browser("DealsDirect.com.au Secure").Page("DealsDirect.com.au Secure_2").WebEdit("cEmail1").Set "hyderabad123@gmail.com"
Browser("DealsDirect.com.au Secure").Page("DealsDirect.com.au Secure_2").WebEdit("cPass1").SetSecure "4e6d78c21597a67d10442192132f29f589ade0eb9021"
Browser("DealsDirect.com.au Secure").Page("DealsDirect.com.au Secure_2").Image("image-login-and-continue-butto").Click 151,17
'Browser("DealsDirect.com.au Secure").Dialog("AutoComplete").WinCheckBox("Don't offer to remember").Set "ON"
'Browser("DealsDirect.com.au Secure").Dialog("AutoComplete").WinButton("Yes").Click

If Browser("DealsDirect.com.au Secure").Page("Online Shopping | Australia").Link("Logout").Exist(10) Then
If Not  Browser("title:=DealsDirect.com.au Secure").Page("title:=Online Shopping | Australia").Link("text:=Login").Exist(10) Then
Msgbox "Logout Link Only Exist"
End If
End If

0 comments:

Post a Comment