Showing posts with label QTP. Show all posts
Showing posts with label QTP. Show all posts

Saturday, September 1, 2018

QTP / UFT Check Points

What is Check Point?
It carries expected value.

Why We are using Check Points in QTP?



Check point Navigations:



1. Standard Check Point: It checks object property values (checking any property value). 

Window based applications:
Window (“Window Name”).Object (“Object Name”). Check Checkpoint (“Checkpoint Name”)

Web based applications:
Browser (“Browser Name”).Page (“Page Name”). Check Checkpoint (“Checkpoint Name”)



Steps:
1. Press .Record <button>, place the cursor in desired location
2. F12 or Insert > CP > Standard CP > show the object > click OK <button>         
    > Selects property and enter expected results & click OK <button>
3. .Stop recording.

2. Text Check Point: It checks object’s text property value in different ways.

Steps: 

1. Press .Record <button>
2. Insert > CP >Text CP > show the object > click OK <button>        
    > Select Option (Match case: ignore spaces, exact match, text not displayed)
     We can select one or more options > Click OK button.
3. .Stop recording.



3. Text Area Check Point: It checks text area present in the application.

Steps: 

1. Press .Record <button>
2. Insert > CP >Text Area CP > mark the area of text           
> Select One or More Option (Match case: ignore spaces, exact match, text not displayed) > Click OK button.     
3. .Stop recording.

4. Bitmap Check Point: It compares bitmaps as well as part of the bitmaps. To verify the area of a web page (or) Application after capturing it as a bitmap.

Steps: 

1. Press .Record <button>
2. Insert > CP >Bitmap CP > shows the bitmap > Click OK Button.        
> Select “check only selected area” option if we want to compare part of the bitmap                 > Click OK button. 
3. .Stop recording.

5. Data Base Check Point: It checks Content of the back-end Data Base.

Steps:
Insert> CP > Data Base Checkpoint > choose “specify SQL statement manually” option
                          > Click Next <Button> > Click Create <Button>
          > Select machine data source > Select DSN (QT_flight32) > Click OK <Button>
          > Enter SQL Statement (select * from orders) > finish > Click OK <Button>
Note: here not in recording mode, no need AUT since data is from back-end
How to Create DSN (Data Source Name):

6. Accessibility Check Point: It checks whether the web page in our web application is developed according to W3C (World Wide Web Consortium) Rules and Regulations or not.

Note: according to our requirements customize this configurable checkpoint:  
Tools <menu> > Options > Select Web > Advanced > Check / Uncheck items > click apply > click OK

Steps:
1. Press .Record >Select Web Environment
2. Insert > CP > Accessibility checkpoint > show the webpage                                                      
                             > Click OK <Button> > Click OK <Button> again.   
3.   .Stop Recording.

7. XML Check Point:

7.1 XML Check Point (From Application): It checks the content of the XML File.

Steps:
1. Press .Record <button> > Select web environment.
2.  Insert <menu> > CP > xml CP (from application) > Browse path of the XML file                                           > click OK <button> > click OK <button> again
3.  .Stop Recording.

Web based applications:

XMLfile(“FileName.XML”). Check Checkpoint (“Checkpoint Name”)

Note: If XML file is part of web application, and if separate path is not available then we can choose inserting XML checkpoints from application.

7.2 XML Check Point (From Resource): It checks the content of the XML File.

Steps: 
Insert <menu> > CP > xml CP (from resource) > Browse path of the XML file > click OK <button> > click OK <button> again

Note: If XML file is an individual and path available, and then we can go for inserting xml checkpoint from resource.

8 Page Check Point: (insert through the Standard Check Point)
It checks number of Links, Images and loading time in a web page.
It is hidden checkpoint;

Steps:
1. Press .Record <button> > Select web environment
2. Insert <menu> > CP > Standard Check Point > show web page
                                     > Click OK <button> > Click OK <button> again.
3.   .Stop Recording.

9 Image Check Point:  (insert through the Standard Check Point)
It checks Image property values.

Steps:
1. Press .Record <button> > Select web environment
2. Insert <menu> > CP > Standard Check Point > show web page
                                     > Click OK <button> > Click OK <button> again.
3.   .Stop Recording.

Web based applications:

Browser (“Browser Name”).Page (“Page Name”). Image(“ Image Name”).Check Checkpoint (“Checkpoint Name”)



10. Table Check Point:  (insert through the Standard Check Point)
It checks the content of the web tables.

Steps:
1. Press .Record <button> > Select the web environment
2. Insert <menu> > CP > Standard Check Point > show web table
                                     > Click OK <button> .               
3. .Stop Recording.

Web based applications:


Browser (“Browser Name”).Page (“Page Name”). WebTable(“Table Name”) Check Checkpoint (“Checkpoint Name”)


Check Points In-Detail:



***

QTP / UFT Methods

Methods or Operations:

.Activate


.Click

.Close


.Set (3 ways: editbox, radiobutton, check boxes)


.Select


.GetVisibleText

.GetROProperty

.GetItemsCount

.Getcontent

.Exist(5)


.Navigate


QTP Methods List:



How to see the object properties by using Obj Spy (cap symbol):

Steps:

1. See the Object Where it is in the Application.

2. Click on the Object Spy (hat symbol)
3. Now open the object spy window on that click on the spy button
4. Click on the Respective object exactly (be care full to click the object)
5. Now object spy will displays that object properties in that take any property.

Note: if u write descriptive programming in those properties copy one or more properties and specify those properties within in the ("----") double quotes.



Web Methods

Browser Object Methods:

1. Close: To Close the Web Browser or Web Application or Windows based Applications.


For Windows Applications:


Syntax: Window("Window Name").Close 
      Ex: Window("Flight Reservation").Close

For Web Applications:


Syntax: Browser("Browser Name").Close 
      Ex: Browser("Google").Close

For any Child (PopUpWindows) in Windows Applications:


Syntax: Dialog("Dialog Name").Close Ex: Dialog("Flight Reservations").Close

For any Child (PopUpWindows) in Web Applications:


Syntax: Browser("Browser Name").Page("Page Name").Dialog("Pop UP Title Name").WebButton("Ok").Click


2. Exist - To check if the object exist or not.


For Windows Applications:


Syntax: Window("Window Name").Exist Ex: Window("Flight Reservation").Exist

For Web Applications:


Syntax: Browser("Browser Name").Exist Ex: Browser("Google").Exist



Detailed Web Validation Example: Google Browser exist or not

If Browser("Google").Exist Then

Browser("Google").Close
Reporter.ReportEvent "micPass", "Status",'Pass"
Else
Reporter.ReportEvent "micFail", "Status",'Fail"
End If


QTP Common Methods

1. Reporter.ReporterEvent: It will displays the Specified Result in the Result Window.

What is the Use is to check if the object exist then that time displays the required result in the result window. At that time we can use.


In this 4 types: 0 or micPass - Pass


1 or micPass - Pass

2 or micFail - Fail
3 or micDone - Done
4 or micWarning -Warning

Ex: Reporter.ReportEvent micPass,"Login Successfully","Test is Pass"



Exercises:
Exercise 1:

The following code is for working under Windows Environment:


Window("Employee").Activate
Window("Employee").WinEdit("Emp Name:").Set "XXXX"
Window("Employee").WinEdit("Emp No: ). Set "12345"
Window("Employee").WinEdit("Emp Sal:).Set "20000"
Window("Employee").WinButton("OK").Click

Exercise 2: 


--

If u are using .Net Add-in with QTP the following Methods appears like Web Methods.

Q: When appears .Net Methods?
Ans: If the Web Page Designed by .Net completetly at that time required .Net Add-in for supporting .NET based web applications. At that time we need to learn .Net methods.
At that time trail QTP was not supported .net designed objects.

coming soooooooooooooooooooooon.



If you are using Java Add-in with QTP the following Methods appears like Web Methods.

Q: When appears Java Methods?
Ans: If the Web Page Designed by Java completetly at that time required Java Add-in for supporting Java based web applications. At that time we need to learn java methods.
At that time trail QTP was not supported with jave designed objects.

so..........on like if u test the sap applications use sap add-in at that time sap methods appears. At that time also qtp trail versison not supported which is designed by sap applications.
later we will discuss sap methods after complition of .net & java methods.

Note: All Methods small difference only. If we know the Web Test Object Methods easy to learn other software add-in object methods also.


1. Method Name:      .Exist 

Ex: 'Login Operation'

SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "abc"
Dialog("Login").WinEdit("Password:").SetSecure "4ebb35f3fd34c48af866bde3b8ae72f9097718b6"
Dialog("Login").WinButton("OK").Click

If Window("Flight Reservation").Exist(10) Then 

Window("Flight Reservation").Close
Result="Logon Successful"
Else
SystemUtil.CloseDescendentProcesses
Result="Login Failed"
End If
Msgbox Result


2. Method Name:      .Select

Ex: Flight From and To 

Window("Flight Reservation").WinComboBox("Fly From:").Select (0)
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20261   DEN   09:12 AM   LON   04:23 PM   AA     $112.20"


3. Method Name:      .GetItemsCount

Item_Count=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
Msgbox Item_Count


4. Method Name:      .GetContent

Item_Count=Window("Flight Reservation").WinComboBox("Fly From:").GetContent
Msgbox Item_Count

5. Method Name:      .GetVisibleText()

Price = Window("Flight Reservation").WinEdit("Price:").GetVisibleText()
Button = Window("Flight Reservation").WinButton("Update Order").GetVisibleText()

Msgbox Price

msgbox Button


6. Method Name:      .GetROProperty()

Price = Window("Flight Reservation").WinEdit("Price:").GetROProperty("text")
Msgbox "Price is: "&Price

x = Window("Flight Reservation").WinEdit("Price:").GetROProperty("enabled")

Msgbox "Enabled vaule is: "&x

x = Window("Flight Reservation").WinEdit("Price:").GetROProperty("width")

Msgbox "Width is: "&x

7. Method Name:      .CaptureBitmap

Dialog("Login").CaptureBitmap "C:\Documents and Settings\Administrator\Desktop\login.bmp"

8. Method Name:      



Examples with GetItemsCount and GetItem:

Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type "121212"
Window("Flight Reservation").ActiveX("MaskEdBox").Type  micTab

n= Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
For i =0 to n-1

 x=Window("Flight Reservation").WinComboBox("Fly From:").GetItem(i)
 Window("Flight Reservation").WinComboBox("Fly From:").Select  x


 m= Window("Flight Reservation").WinComboBox("Fly To:").GetItemsCount
     For j=0 to m-1 step 1
        y=Window("Flight Reservation").WinComboBox("Fly To:").GetItem(j)
        'Window("Flight Reservation").WinComboBox("Fly To:").Select  y
              If  x=y  Then
               Reporter.ReportEvent micFail,"Same exist in Fly To also","Test Fail"
              else
               Reporter.ReportEvent micFail,"Not exist in Fly To ","Test Pass"
              End If
     Next
Next
------------------------------------------------------------------------------------------

a=10

b=10
x= a+b

If x= 30 Then
          Reporter.ReportEvent micPass,"additon","Pass"
else
    Reporter.ReportEvent micFail, "additon", "Fail"

End If



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

x = Dialog("Login").WinButton("OK").GetVisibleText
msgbox x

y = Dialog("Login").WinButton("Cancel").GetVisibleText()
msgbox y

w = Dialog("Login").GetVisibleText()
msgbox w

----------------------------------------------------
w1 = Dialog("Login").GetROProperty("text")
msgbox w1

t1 = Dialog("Login").GetTOProperty("text")
msgbox w1



x = Window("Flight Reservation").WinEdit("Tickets:").GetROProperty("text")
msgbox x

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

Sub Se()
x = Window("Flight Reservation").SetTOProperty "Index", 2
msgbox x
End Sub

Call Se()


***

QTP / UFT Descriptive Programming

1. What is Descriptive Programming?

2. Why we are using Descriptive Programming in QTP?
     No need to use Object Repository.
     Execution is very faster than Object Repository.

3. Explain about Description Object?

4. How to write Descriptive Programming?
    Two ways we can write the Descriptive Programming.
    1. Static Programming
    2. Dynamic Programming

4.1 Static Programming:
    Again Two ways we can write the Descriptive Programming.
    4.1.1. using Variable: assign the objects description to the Variable. That variable we can use in the Programme. That variables called Constant Variables.

Ex 1: Write a Descriptive Program for Flight Application Login Window and File>Open Order.

SystemUtil.Run "D:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

Const ologin = "regexpwndtitle:=Login", oagentname = "attached text:=Agent Name:"
Const opwd  = "attached text:=Password:", ook = "text:=OK"

Dialog(ologin).Activate
Dialog(ologin).WinEdit(oagentname).Set "test"
Dialog(ologin).WinEdit(opwd).SetSecure "4f02d6be35088fb2e778a58de61fd083e7a0522a"
Dialog(ologin).WinButton(ook).Click

Const ofrw = "regexpwndtitle:=Flight Reservation" 
Const oopenorderw = "regexpwndtitle:=Open Order"
Const ocheckbox = "regexpwndtitle:=&Order No."
Const oopenordereditbox = "abs_x:=269"
Const ook2 = "abs_x:=338"

Window(ofrw).Activate
Window(ofrw).WinMenu("menuobjtype:=2").Select "File;Open Order..."
Window(ofrw).Dialog(oopenorderw).WinCheckBox(ocheckbox).Set "ON"
Window(ofrw).Dialog(oopenorderw).WinEdit(oopenordereditbox).Set "5"
Window(ofrw).Dialog(oopenorderw).WinButton(ook2).Click
Window(ofrw).Close

4.1.2. Directly write the objects description in the Programming itself. Whatever objects description assign to the variables in the above example here Directly mention the objects description in the Programme.

Ex 1: Write a Descriptive Program for Flight Application Login Window and File>Open Order.

SystemUtil.Run "D:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

Dialog("regexpwndtitle:=Login").Activate
Dialog("regexpwndtitle:=Login").WinEdit("attached text:=Agent Name:").Set "test"
Dialog("regexpwndtitle:=Login").WinEdit("attached text:=Password:").SetSecure "4f02d6be35088fb2e778a58de61fd083e7a0522a"
Dialog("regexpwndtitle:=Login").WinButton("text:=OK").Click

Window("regexpwndtitle:=Flight Reservation).Activate
Window("regexpwndtitle:=Flight Reservation).WinMenu("menuobjtype:=2").Select "File;Open Order..."

Window("regexpwndtitle:=Flight Reservation).Dialog("regexpwndtitle:=Open Order").WinCheckBox("regexpwndtitle:=&Order No.").Set "ON"

Window("regexpwndtitle:=Flight Reservation).Dialog("regexpwndtitle:=Open Order").WinEdit("abs_x:=269").Set "5"

Window("regexpwndtitle:=Flight Reservation).Dialog("regexpwndtitle:=Open Order").WinButton("abs_x:=338").Click

Window("regexpwndtitle:=Flight Reservation).Close 

4.2 Dynamic Programming:




SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("text:=Login").Activate
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "abcd"
Dialog("text:=Login").WinEdit("attached text:=Password:").SetSecure "4ebc825c46d0b97f638a02d2733ba25883501cea"
Dialog("text:=Login").WinButton("text:=OK").Click
-----------------------------------------------------------------------------------------

If  Not Dialog("text:=Login").Exist(3) Then
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
End If
Dialog("text:=Login").Activate
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "abcd"
Dialog("text:=Login").WinEdit("attached text:=Password:").SetSecure "4ebc825c46d0b97f638a02d2733ba25883501cea"
Dialog("text:=Login").WinButton("text:=OK").Click
------------------------------------------------------------
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("text:=Login","index:=0").Activate
Dialog("text:=Login","index:=0").WinEdit("attached text:=Agent Name:").Set "abcd"
Dialog("text:=Login","index:=0").WinEdit("attached text:=Password:").SetSecure "4ebc825c46d0b97f638a02d2733ba25883501cea"
Dialog("text:=Login","index:=0").WinButton("text:=OK").Click
-----------------------------------------------------------------------------------
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Set x=Dialog("text:=Login","index:=0")
x.Activate
x.WinEdit("attached text:=Agent Name:").Set "abcd"
x.WinEdit("attached text:=Password:").SetSecure "4ebc825c46d0b97f638a02d2733ba25883501cea"
x.WinButton("text:=OK").Click
--------------------------------------------------------------------------------
Const Login="text:=Login", Agent="attached text:=Agent Name:", Password="attached text:=Password:"
Const Ok1="text:=OK", Ok2="width:=60", Ok3="height:=23"

SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(Login).Activate
Dialog(Login).WinEdit(Agent).Set "abcd"
Dialog(Login).WinEdit(Password).SetSecure "4ebc825c46d0b97f638a02d2733ba25883501cea"
Dialog(Login).WinButton(Ok1,Ok2,Ok3).Click
-----------------------------------------------------------------------------------------------------
'Create Collection Objects
Set Login=Description.Create
Set Agent=Description.Create
Set Password=Description.Create
Set Ok=Description.Create

'Enter Properties Information into Collection Objects
Login("text").value="Login"
Login("height").value=204
Login("enabled").value=True

Agent("attached text").value="Agent Name:"
Agent("window id").value=3001
Agent("x").value=20

Password("attached text").value="Password:"
Password("height").value=20
Password("visible").value=True

Ok("text").value="OK"

'Generate Statements using Collection Objects
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(Login).Activate
Dialog(Login).WinEdit(Agent).Set "abcd"
Dialog(Login).WinEdit(Password).Set "mercury"
Dialog(Login).WinButton(Ok).Click
-----------------------------------------------------------------------------------------
Executefile "Obj.vbs"
'Generate Statements using Collection Objects
Set a=Dialog(Login)
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
a.Activate
a.WinEdit(Agent).Set "abcd"
a.WinEdit(Password).Set "mercury"
a.WinButton(Ok).Click

=============
static programming:

Const oLogin= "text:=Login"
Const oAgent = "attached text:=Agent Name: ","width:=320"
Const oPwd= "attached text:=Password:"
Const oOk = "text:=OK"

SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

Dialog(oLogin).Activate 
Dialog(oLogin).WinEdit(oAgent).Set "abcd"
Dialog(oLogin).WinEdit(oPwd).Set "mercury"
Dialog(oLogin).WinButton(oOk).Click 
-------------------------
dynamic programming:

method2:


file-> settings-->resources->browse the .vbs file


Set oLogin =Description.Create

Set  oAgent = Description.Create
Set  oPwd = Description.Create
Set  oOk=Description.Create


oLogin("text").Value = "Login"

oLogin("width").Value=320
oAgent("attached text").Value ="Agent Name:"
oPwd("attached text").Value ="Password:"
oOk("text").Value = "OK"

qtp main test:


Dialog(oLogin).Activate 

Dialog(oLogin).WinEdit(oAgent).Set "abcd"
Dialog(oLogin).WinEdit(oPwd).Set "mercury"
Dialog(oLogin).WinButton(oOk).Click 


=======================================================================

SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

With Dialog("Login")
                     .Activate
                              .WinEdit("Agent Name:").Set "asdklf"
                              .WinEdit("Password:").SetSecure "509899fbe0af394d150a0653ed001e5f03af6fe5"
                              .WinButton("OK").Click
                   Window("Flight Reservation").Activate
                   Window("Flight Reservation").Close
End With


SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

With Dialog("Login")
                     .Activate
                              .WinEdit("Agent Name:").Set "asdklf"
                              .WinEdit("Password:").SetSecure "mercury"
                              .WinButton("OK").Click
End With


'regexpwndtitle:=Login
'attached text:=Agent Name:
'attached text:=Password:
'regexpwndtitle:=OK

Const  ologin = "regexpwndtitle:=Login", oagent = "attached text:=Agent Name:"
Const  opwd =  "attached text:=Password:",   ook = "regexpwndtitle:=OK"

SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(ologin).Activate
Dialog(ologin).WinEdit(oagent).Set "abcd"
Dialog(ologin).WinEdit(opwd).Set "mercury"
Dialog(ologin).WinButton(ook).Click




Method 2:


SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("regexpwndtitle:=Login").Activate
Dialog("regexpwndtitle:=Login").WinEdit("attached text:=Agent Name:").Set "abcd"
Dialog("regexpwndtitle:=Login").WinEdit("attached text:=Password:").Set "mercury"
Dialog("regexpwndtitle:=Login").WinButton("regexpwndtitle:=OK").Click




Method 3:



Set ologin = Description.Create()
Set oagent = Description.Create()
Set opwd = Description.Create()
Set ook = Description.Create()

ologin("text").Value = "Login"
ologin("regexpwndtitle").Value="Login"
oagent("attached text").Value = "Agent Name:"
opwd("attached text").Value = "Password:"
ook("text").Value = "OK"

SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(ologin).Activate
Dialog(ologin).WinEdit(oagent).Set "abcd"
Dialog(ologin).WinEdit(opwd).Set "mercury"
Dialog(ologin).WinButton(ook).Click




   or

Note: without using tools options in qtp

Executefile "C:\Documents and Settings\Administrator\Desktop\desobjpro.vbs"

SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(ologin).Activate
Dialog(ologin).WinEdit(oagent).Set "abcd"
Dialog(ologin).WinEdit(opwd).Set "mercury"

Dialog(ologin).WinButton(ook).Click

Featured Post

How To Change Width & Height of Blogger's Top Menu Bar