Monday, 10 February 2014

QTP Methods

Methods or Operations: .Activate .Click .Close .Set (3 ways: editbox, radiobutton, check boxes) .Select .GetVisibleText .GetROProperty .GetI... thumbnail 1 summary
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):

Navigation:

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:
Syntax1: Window("Window Name").Close 
          Ex: Window("Flight Reservation").Close

For Web Applications:
Syntax 2: Browser("Browser Name").Close Ex: Browser("Google").Close

For any Child (PopUpWindows) in Windows Applications:
Syntax 3: Dialog("Dialog Name").Close Ex: Dialog("Flight Reservations").Close

For any Child (PopUpWindows) in Web Applications:
Syntax 4: 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:
Syntax1: Window("Window Name").Exist Ex: Window("Flight Reservation").Exist

For Web Applications:
Syntax 2: 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:
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
Ex:
Item_Count=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
Msgbox Item_Count


4. Method Name:      .GetContent
Ex:
Item_Count=Window("Flight Reservation").WinComboBox("Fly From:").GetContent
Msgbox Item_Count

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

Msgbox Price
msgbox Button


6. Method Name:      .GetROProperty()
Ex:
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
Ex:
Dialog("Login").CaptureBitmap "C:\Documents and Settings\Administrator\Desktop\login.bmp"

8. Method Name:      .
Ex:


9. Method Name:      .
Ex:


10. Method Name:      .
Ex:


11. Method Name:      .
Ex:


3. Method Name:      .
Ex:


3. Method Name:      .
Ex:


3. Method Name:      .
Ex:



Examples with GetItemsCount & 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()







No comments

Post a Comment