Sunday, 23 September 2012

QTP Methods / Operations




 QTP Methods / Operations
1) Activate Method

It activates dialog boxes/Windows

Syntax: Object hierarchy. Activate
 Ex:
Dialog(“Login”).Activate
Window(“Flight Reservation”).Activate

2) Click Method
It clicks on an object (Buttons)
Syntax: Object hierarchy. Click
Ex:
Dialog(“Login”).Winbutton(“ok”).click

3) Close Method
It closes the window,Dialog box, Browser window etc.
Syntax: Object hierarchy. Close
Ex:
Window(“Flight Reservation”).Close
Browser(“Browser”).Close

4) Dblclick 
It Double clicks the object.

5) Set Method
It can be used in three ways.
a. For setting the value of an edit box
Syntax: Object Hierarchy. SET “Value”
Ex: Dialog (“Login”).WinEdit(“Agent Name”).Set “asdf”

b. Selecting a Radio Button
Syntax: Object Hierarchy. Set
Ex: Window("Flight Reservation").WinRadioButton("Business").Set

c. Selecting/Deselecting check boxes
Syntax:object Hierarchy.Set “ON/off”
Ex: Window ("Flight Reservation"). Dialog("Open Order").WinCheckBox("Order No.").Set "ON"

6) Select Method:
It is used for selecting an item from a combo box or list box.
Syntax: Object hierarchy.select “item”
Ex:
Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "12572

7) GetVisibletext: It returns Text from the specified area.
Syntax: Variable =object hierarchy.getvisibletext
Ex:
x=Window("Flight Reservation").WinComboBox("Fly From:").GetVisibleText
msgbox x

8) GetRoproperty:
It returns current object property value. It can be used for getting any object’s, any property value.
Syntax: Variable = object hierarchy.getroproperty (“property name”)
Ex: x=Window("Flight Reservation").WinEdit("Tickets:").GetROProperty ("width")
msgbox x

9) Navigate Method:
It opens a specified URL in the Browser.
Syntax: object hierarchy.navigate “URL”
Ex: Browser("Yahoo!").Navigate http://www.google.co.in/

10) Getitemscount: It returns number of items in a combobox.
Syntax: Variable=object hierarchy.getitemscount
Ex: x=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
msgbox x

11) Getcontent: It returns all items from a combobox.
Syntax: variable=object hierarchy.GetContent
Ex: x=Window("Flight Reservation").WinComboBox("Fly From:").GetContent
msgbox x

12) Exist property: It checks whether the object is available or not.
Syntax: Object hierarchy.exist(time in seconds)
Ex: Window("Flight Reservation").Exist(5)
QTP Data Table Methods

(1) Add Sheet:
We can use this method to “add” one new sheet to the run time data table.
Syntax: DataTable.AddSheet "sheet name"
Ex: DataTable.AddSheet "gcreddy"

(2) Delete Sheet:

We can use this method to “delete” one specified sheet from the Run Time Data table.


Syntax: datatable.DeleteSheet (Sheet_ID)
Ex: datatable.DeleteSheet (3)


(3) GetSheetCount

We can use this method to count number of sheets in the run time data table.


Syntax:
datatable.GetSheetCount
msgbox datatable.GetSheetCount

(4) GetRowCount


We can use this method to count number of rows in the 1st sheet
(longest column) of the Run time data table.


Syntax: datatable.GetRowCount


Ex: msgbox datatable.GetRowCount

(5) GetSheet


We can use this method to return a specified sheet from the Run Time data table.


Syntax: datatable.GetSheet(SheetID)


Ex: msgbox datatable. GetSheet(1).GetRowCount


(6) Value

We can use this method to set or get value of cell in the specified parameter and the current row of the Rum time data table.


To set data


Syntax: datatable.Value(Parameter_Name, Sheet_Name) = Value / variable Or

datatable(Parameter_Name, Sheet_Name) = Value / variable


To get data

Syntax: Variable = datatable.Value(Parameter_Name, Sheet_Name) Or

Variable = datatable(Parameter_Name, Sheet_Name)


Ex:

Option explicit Dim a, b, c


a=datatable.Value (1,1) b=datatable.Value (2,1) c=cint(a)+cint(b) datatable.Value (3,1) = c

Note: Default property of Datatable is value

(7) SetCurrentRow


We can use this method to take a specified row as current row in the Run Time Datatable (By default it is 1st Row of 1st Sheet)

Syntax: datatable.SetCurrentRow(Row_Number)

g="gcreddy"

datatable.SetCurrentRow (3) datatable.Value (1,1) = g


(8) SetNextRow


We can use this method to take the row after the current Row as New Current Row in the Run time data table.


Syntax: datatable.SetNextRow

Ex: g="gcreddy"

datatable.SetCurrentRow (3) datatable.SetNextRow datatable.Value (1,1) = g


(9) SetPrevRow

We can use this method to take the row before the current Row as New Current Row in the Run time data table.


Syntax: datatable.SetPrevRow


Ex: g="gcreddy"


datatable.SetCurrentRow (3) datatable.SetPrevRow datatable.Value (1,1) = s


(10) Import

We can use this method to import Microsoft Excel File to the Runtime Data Table (Including all sheets)


Syntax: datatable.Import “Path of File”

Ex: datatable.Import “F:\Inputdata.xls”

11) ImportSheet

We can use this method to import a specified sheet of Microsoft Excel Sheet to the Runtime Data table.


Syntax: datatable.ImportSheet “Path of File”, “Source Sheet”, “Destination Sheet”

Ex: datatable.ImportSheet “E:\gcreddy.xls”,3,1

(12) Export


We can use this method to export a copy of Run Time Data table to another location (Including all sheets)


Syntax: datatable.Export “Path of File”


Ex: datatable.Export “F:\gcreddy.xls”


13) ExportSheet


We can use this method to export a copy specified sheet of Run Time Data table to the existing or new Excel File.

Syntax: datatable.ExportSheet “Path of File”, “Sheet Name / Source Sheet”


Ex: datatable.ExportSheet “F:\anji.xls”, 2
Data Driven Testing for Login Operation using Data Table methods


Datatable.AddSheet "Login"
Datatable.ImportSheet "C:\Documents and Settings\gcr\Desktop\gcreddy.xls",1,3
Rows_count=Datatable.GetSheet(3).GetRowCount

For i= 1 to Rows_count
    Datatable.SetCurrentRow(i)
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Datatable("Agent",3)
Dialog("Login").WinEdit("Password:").Set Datatable("Pwd",3)
Dialog("Login").WinButton("OK").Click

If window("Flight Reservation").exist(10) Then
    Login="Login Operation Successful"
    Datatable("Result",3)=Login
    Reporter.ReportEvent micPass,"res","Passed"
    else
Reporter.ReportEvent micFail,"res","Failed"
Login="Login Operation Failed"
Datatable("Result",3)=Login

Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Cancel").Click
End If

If Window("Flight Reservation").Exist(3)Then
    Window("Flight Reservation").Close
    End if
Next
Synchronization
It is a process of matching the speeds of both QTP and AUT in order to get proper execution and results.


Where Synchronization is required:

During test execution QTP gives instructions one by one with same speed, but AUT takes less time for some operations execution and more time for some operations execution, that time we may not get proper execution and results. In order to get proper results in between QTP & AUT synchronization is required.

There are several methods available in QTP for synchronization.

1. Inserting Wait statements.
2. Inserting Synchronization points.
3. Increasing Tool default synchronization time.
4. Sync Method (Only for WEB)
5. Exist Property

Inserting Wait Statements:
We can insert wait statements in our test in order to make QTP to wait until AUT completes current operation.
Syntax: Wait(time in seconds)

Note: If we insert wait statements QTP waits up to maximum time even though operation is completed.

Inserting Synchronization points:

Place cursor in desired location>keep tool under recording mode>Insert menu>Synchronization point >show the object >click ok>select property name & Value(True)>enter time in Milli seconds>click ok>Stop recording.

Note: if we insert Synchronization points, it does not wait up to maximum time, after completion of the current operations, it goes to next step immediately.

Syntax: object hierarchy.waitproperty “property name”,value,time in milli seconds.

Increasing Tool default synchronization time:

Navigation: File>settings>run tab>increase object synchronization time out>apply>ok
Note: If we increase QTP tool default time that can be applied for all statements in the test, but QTP does not wait up to maximum time unnecessarily, After completion of one statement execution it goes to next statement immediately.

Sync Method: (only for WEB)
Waits for the browser to complete current navigation.

Syntax: Object Hirearchy.Sync
Ex: Browser("Yahoo! Toolbar").Page("Yahoo! Toolbar").Sync

Selecting an appropriate Method:

1. Suppose in our test one or more statements only are taking more time for execution then selecting “Inserting synchronization method” is better.

2. Suppose in our test more statements are taking more time for execution then selecting “increasing tool time out” .

3. Above two are local features but wait statement is Vbscript feature, even though some drawbacks are there in using wait statement, it is better to use wait statement in functions.

Advantages of Wait Statement:
1)  It is a VBScript statement, we can use this globally

2) It is recommended, whenever we want to observe the Test Execution process
3) No object reference required to insert wait statements

4) It is useful to make QTP capture values and screen shots during test execution

QTP Questions



 

  QTP general and basic Questions


1. What is the difference between high level design and low level design?
2.    How to write Test cases for Login screen?
3.    How to write Test Case for telephone ?
4.    What Is NUnit?
5.    Give me full explanation for SDLC process.
6.    What should test in BANKING DOMAIN application ?
7.    How search button of a web application can be tested both Manually and using QTP8.2?
8.    What's server side testing
9.    Give some examples of Low Severity and Low Priority Bugs High Severity and Low Priority Bugs Low Severity and High Priority Bugs High Severity and High Priority Bugs ?
10.                        What is the BEST WAY to write test cases?
11.                        How to calculate the estimate for test case design and review?
12.                        What is API Testing?
13.                        What's normal practices of the QA specialists with perspective of software?
14.                        Reliability, Usability and Testability. Explain why you would test for these factors?
15.                        What is an exit and entry criteria in a Test Plan ?
16.                        What if the software is so buggy it can't be tested at all?
17.                        What is SQA Activities?
18.                        What is that column "steps to reproduce" mean in bug tracking? 1
19.                        How to test a web application, for security testing of Web Application?
20.                        Describe to the basic elements you put in a defect report?
21.                        What is SQA Activities?
22.                        What's the difference between Alpha, Beta and User Acceptance testing?
23.                        How can u test the white page
24.                        What are the responsibilities of a QA engineer?
25.                        What are some of the software configuration management tools?
26.                        Explain about Metrics and types of metrics like schedule variance , effort variance?
27.                        What is the exact difference between functional and non functional testing?
28.                        What is "bug leakage?" and what is "bug release?"
29.                        What makes a good QA/Test Manager?
30.                        Write one test case describing the expected results according to the user's rights? It is logical to be described different expected results for one action?
31.                        What do you mean by Software Quality Assurance?
32.                        What is the difference between the test case and a test script
33.                        What kind of automated software used to test a Web-based application with a .NET (ASP.NET and C#...also SQL Server) framework?
34.                        Difference between Verification and Validation?
35.                        What is SRS and BRS and what is the difference between them?
36.                        Whats the difference between ISO vs CMM ?
37.                        Need some QA advice: * Improve Management Commitment to Quality Assurance * Improve the Internalization Quality Assurance as a process
38.                        What are the bottlenecks involved in performance testing?
39.                        What is defect leakage?
  Software Testing Interview Questions  
1.    What makes a good Software Test engineer?
2.    What makes a good Software QA engineer?
3.    What makes a good QA or Test manager?
4.    What's the role of documentation in QA?
5.    What's the big deal about 'requirements'?
6.    What steps are needed to develop and run software tests?
7.    What's a 'test plan'?
8.    What's a 'test case'?
9.    What should be done after a bug is found?
10.                        What is 'configuration management'?
11.                        What if the software is so buggy it can't really be tested at all?
12.                        How can it be known when to stop testing?
13.                        What if there isn't enough time for thorough testing?
14.                        What if the project isn't big enough to justify extensive testing?
15.                        How does a client/server environment affect testing?
16.                        How can World Wide Web sites be tested?
17.                        How is testing affected by object-oriented designs?
18.                        What is Extreme Programming and what's it got to do with testing?
19.                        What is mean by software engineering?
20.                        Who actually perform Alpha testing?Both developer and customer or only customer?
21.                        Who actually perform Alpha testing?Both developer and customer or only customer?
22.                        What is Compatability Testing? and What are all the procedures to conduct Compatability Testing?
23.                        Traceability matrix, test strategy
24.                        wats the difference between run time object and test object in QTP
25.                        What is ERP Testing?
26.                        When we use update mode in QTP?
27.                        Pleese tel me about STLC clearly and Buglifecycle
28.                        What is bi-directional traceability matrix? Give sample format?
29.                        Whats the difference betweeen the 'V' shape and 'U' shape.
30.                        What is calling to copy of action and calling to existing action?
31.                        What is the major Defect in Bugzilla defect tracking tool when compared with the other defect tracking tools?
32.                        What are the types of flat files in QTP supports?
33.                        why we need documents for testing?
34.                        What is SDLC and STLC and the different phases of both? What is the difference between system testing and functional testing?
35.                        what is meant by get Ro property and set to property in QTP
36.                        What is mean by data flow diagram? What is the difference between the data flow diagram and flow chart?
37.                        Generate test cases for replace string method
38.                        what are the components of testing?
39.                        What is meant by fault/bug density ,how do u calculate this.
40.                        What Is Test Bed?
  Automated Testing Tools Interview Questions  
1.    Define virtual object in QTP?
2.    What is reusable action in QTP?
3.    How did you use automating testing tools in your job?
4.    What automating testing tools are you familiar with?
5.    What is alfa testing and beta testing in QTP?
6.    Define two logs standard log and extended log in load runner?
7.    What is ORD parameter?
8.    How will you choose a tool for test automation?
9.    When we use update mode in QTP?
10.                        Which automated testing tools is used for SAP R3 ABAP?
11.                        What is elapsed time?
12.                        How Does Run time data (Parameterization) is handled in QTP?
13.                        How you will evaluate the tool for test automation?
14.                        What is regular expression in QTP?
15.                        What is pacing time in Load runner?
16.                        Discuss QTP Environment.
17.                        What is threshold time in load runner Can you explain?
18.                        What is connection pooling in Load runner?
19.                        Explain the terms Test Object Model, Test Object & Run-Time object?
20.                        What is the use of systemutil.run? how we can test the weblinks? what is the difference between QTP and winrunn