Monday, January 31, 2011

Download free QTP Framwork: How to Implement framework in QTP

How To Make Career In QTP: Download free QTP Framwork

for Technical interviews:

http://no1tutorial.com/

learn step by step technologies:


http://no1tutorial.com/
Framework Implementation in QTP

The Keyword-driven Framework is an application independent framework

that performs all possible actions and verifications on an object.
Hence, the code for the same object can be used across different
applications.
2.1. Test Settings for Keyword-driven Scripting
In the keyword-driven approach the entire script is developed with
keywords. The script is developed in a spreadsheet that is
interpreted by the main driver script, which then uses the function
library to execute the complete script.
The QTP Settings.vbs file can be used to easily perform the test
settings that are needed before proceeding with the Keyword-driven
Scripting. This file associates the Function libraries, recovery
scenarios, Environment Variables and the Object Repository files that
are needed for a script.
The QTP Settings file needs to be customized before usage. Edit the
.vbs file in notepad and make the necessary changes (mentioned below)
in the ‘Input Data’ section of the file.
1. Function Libraries – Specify the path where the Framework
Files, Common Functions and the User Defined Functions are
stored.
2. Recovery Scenario File - Specify the path of the file where the
Recovery scenarios are placed.
3. Recovery Scenarios Name - Specify the names of the Recovery
scenarios that need to be associated to the test script.
4. Environment File - Specify the path of the xml file for the
Global Environment Variables.
5. Object Repository files - Specify the path of the Object
Repository.
Open the test script in QTP for which the settings are needed and
double click on the QTP Settings.vbs file. This file will perform the
preferred settings automatically.

If there are multiple items of libraries, object repositories or global variables file,
they can be specified as an array separated by ‘,’

Set the Flag envi_flag, recover_flag, repos_flag, library_flag to "Yes" if the
corresponding files need to be associated to test, Else set it to "no"


given below is a sample “QTP Settings”.
libraries= array ("C:\WebFramework.vbs","C:\common functions.vbs")
recovery_file= "C:\recover.qrs"
recovery_name=array("Scenario1","Scenario2")
environment_file= "C:\Environment.xml"
repository_name= array ("C:\repository1.tsr","C:\repository2.tsr")
'NOTE: Please set the Flag to "Yes" if the files are to be associated to
test, otherwise set it to "no"
envi_flag="yes"
recover_flag=" yes"
repos_flag=" yes"
library_flag=" yes"
There should be just one Recovery file which holds all the Recovery scenarios. Multiple
Recovery files cannot be used.
There should be no unsaved tests currently open in QTP. The test script for which the test
settings need to be done should be open in QTP.

2.1.1. Run Settings

In the Run tab of the Test Settings dialog,
1. The Run one iteration only radio button will be selected.
2. The Disable Smart Identification during the run session check box
will be checked.
3. The Object Synchronization timeout value will be set as 20
seconds.

2.1.2. Resources Settings

After the run settings are completed, the QTP Settings file
associates the framework with the test script. Here, the path and the
names of the framework files need to be specified in the QTP Settings
file. The framework will be taken from the location specified and
associated with the test as shown below.

Associating Framework File

NOTE: The Common functions file and the User defined functions file should be
associated with the test only if needed by the test script.

2.1.3. Environment Tab Settings
QTP can insert a value from the environment variable list, which is a
list of variables and corresponding values that can be accessed from
the test. Throughout the test run, the value of an environment
variable remains the same, regardless of the number of iterations,
unless the value of the variable is changed programmatically in the
script.
Associating the user-defined Environment Variables file with the test
is also handled by the QTP Settings file. The Environment Variables
file with an .xml file type will be taken from the path specified in
the QTP Settings file and associated with the test.

Loading Environment Variables from xml File

2.2. Managing Object Repository

After the test settings are completed, the QTP Settings file
continues to associate the specified shared object repositories with
the test. The objects from the shared repository will be uploaded and
made available for the tests.

Associate Repositories Dialog


Call to Framework

The call to Keyword_Driver() needs to be specified in the Expert View
as shown below. This will call the Framework file associated with the
test and perform the actions by interpreting the keywords specified
in the data table.

2.4. Usage of Keywords

The keywords should be entered in the global sheet of the data table
of the test according to the syntax. To access the data table, choose
View > Data Table or click on the toolbar button. Below is an
example of Keyword-driven Scripting.

Using the keyword in a Data Table


2.5. Test Results for a Keyword-driven Script
Test execution results can be viewed and analyzed as soon as the run
session ends. To access the test results, choose Automation > Results
or click on the toolbar button. The results window will be
displayed.

Results in QTP

VB Scripting for beginners

for Technical interviews:

http://no1tutorial.com/

learn step by step technologies:


http://no1tutorial.com/
VB Scripting:
Once the script is generated by recording, we may want to enhance the script to make it more effective. QTP allows you to do this with the help of VB script language elements. Following are some of the VB Script language elements that are commonly used.

Command: InputBox.
Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns the contents of the text box.
Syntax: InputBox(“Enter your name”)
Command: MsgBox.
Displays a message in a dialog box, waits for the user to click a button, and returns a value indicating which button the user clicked.
Syntax: MsgBox(“Hello World”)



String Functions:
StrComp: Returns a value indicating the result of a string comparison.
Usage:
A=Strcmp(“Hello”,”Hello”)
A will have value 0 which means true.
InStr: Returns the position of the first occurrence of one string within another
Usage:
val1="welcome to India"
val2="India"
val=InStr(1,val1,val2)
val will have value 12 . This means that the position of the word India in val1 is 12.

Split: Returns a zero-based, one-dimensional array containing a specified number of substrings with respect to delimiter.
Usage:
Val=”appleXballXcatXdog”
Sval=Split(val,”X”,-1)
Now Sval(0) will have apple
Sval(1)=ball
Sval(2)=cat.
That is Split command will split the string based upon the delimiter specified.



Date and Time Functions:
Now: Returns the current date and time according to the setting of your computer's system date and time.
Usage:
Dim MyVar
MyVar = Now ' MyVar contains the current date and time.

DateAddf: Returns the number of intervals between two dates
Usage:
DiffADate = "Days from today: " & DateDiff("d", Now,"2/7/2008" )
MsgBox DiffADate
DiffADate will have the no of days between today and "2/7/2008"

DateAdd: Returns a date to which a specified time interval has been added.
Usage:
NewDate = DateAdd("m", 1, "31-Jan-95")
The NewDate will be “28-Feb-95”. One month latter than “31-Jan-95”

Day(now): This will return todays day alone. Like 21, 15 or 12
Hour(now): This will retun the current hour alone.




User Defined Function:
Example Function
Public Function Total(a,b, ByRef c)
c=a+b
End Function
Call Total(2,3,d)
D will have the output, the value of c.
Syntax For Writing a Function.
[Public [Default] | Private] Function name [(arglist)]
[statements]
[statements]
End Function

Public
Indicates that the Function procedure is accessible to all other procedures in all scripts.
Default
Used only with the Public keyword in a Class block to indicate that the Function procedure is the default method for the class. An error occurs if more than one Default procedure is specified in a class.
Private
Indicates that the Function procedure is accessible only to other procedures in the script where it is declared or if the function is a member of a class, and that the Function procedure is accessible only to other procedures in that class.
name
Name of the Function; follows standard variable naming conventions.
arglist
List of variables representing arguments that are passed to the Function procedure when it is called. Commas separate multiple variables.
statements
Any group of statements to be executed within the body of the Function procedure.
File handling:
Writing Values From a File:
Const ForReading = 1, ForWriting = 2
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
MyFile.WriteLine "Hello world!"
MyFile.WriteLine "The quick brown fox"
MyFile.Close

Reading Values from a File:
Const ForReading = 1, ForWriting = 2
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile("c:\testfile.txt", ForReading)
Val= MyFile.ReadLine
Val1=MyFile.ReadLine
MyFile.Close

Fetching Values from a Database using VBScript.
Set MyConn = CreateObject("ADODB.Connection")
MyConn.Open"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Program”+_ "Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb"
Set RS = MyConn.Execute("SELECT * FROM Orders")
While Not RS.EOF
msgbox RS("Order_Number").Value
Rs.MoveNext
Wend
QTP’S test Object Functions:
Exist: You can enter Exist and/or Wait statements to instruct QuickTest to wait for a window to open or an object to appear. Exist statements return a boolean value indicating whether or not an object currently exists. Wait statements instruct QuickTest to wait a specified amount of time before proceeding to the next step. You can combine these statements within a loop to instruct QuickTest to wait until the object exists before continuing with the test.
Example:
blnDone=Window("Flight Reservation").Dialog("Flights Table").Exist
counter=1
While Not blnDone
Wait (2)
blnDone=Window("FlightReservation").Dialog("FlightsTable").Exist counter=counter+1
If counter=10 then
blnDone=True
End if
Wend
Check Property: Checks whether the specified object property achieves the specified value within the specified timeout.
Syntax: object.CheckProperty (PropertyName, PropertyValue, [TimeOut])
Example:
var_CheckProperty = Browser("HP QuickTest Professional").Page("HP QuickTest Professional").Link("1.2 License Models").CheckProperty("text", "Licence Models")
Return Value
A Boolean value. Returns TRUE if the property achieves the value, and FALSE if the timeout is reached before the property achieves the value.
A TRUE return value reports a Passed step to the test results; a FALSE return value reports a Failed step to the test results.

GetTOProperty: Returns the value of the specified property from the test object description.
Syntax: object.GetTOProperty (Property)
Example : var_GetTOProperty = Browser("HP QuickTest Professional").Page("HP QuickTest Professional").Link("1.2 License Models").GetTOProperty("Innertext")
Return Value: A variant value which will have the inner text of the link “1.2 License Models”
GetROProperty: Returns the current value of the test object property from the object in the application.
Syntax: object.GetROProperty (Property)
Example : var_GetTOProperty = Browser("HP QuickTest Professional").Page("HP QuickTest Professional").Link("1.2 License Models").GetROProperty("Innertext")
Return Value: A variant value which will have the current inner text value of the link “1.2 License Models”



ReportEvent : Reports an event to the test results
Syntax: Reporter.ReportEvent EventStatus, ReportStepName, Details [, Reporter]
Example:
Reporter.ReportEvent 1, "Custom Step", "The user-defined step failed."
or
Reporter.ReportEvent micFail, "Custom Step", "The user-defined step failed."

SystemUtil.Run : You can run any application from a specified location using a SystemUtil.Run statement
Example:SystemUtil.Run"C:\ProgramFiles\InternetExplorer\IEXPLORE.EXE","","C:\Documents and Settings\Administrator","open"
The statement opens the Internet Explorer.

ExecuteFile: This can be used to execute an external VB Script File
Syntax: ExecuteFile FileName
Example : ExecuteFile “C:\sample.vbs”
The above discussed functions can be easily Accessed by step Generator:

How to connect Database in QTP?

dim objDB
dim objRS
dim intCounter



' create a database and recordset objects
Set objDB = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.RecordSet")



' configure the connection
objDB.Provider="Microsoft.Jet.OLEDB.4.0"
objDB.Open "c:\MyTestDatabase.mdb"



' count the number of records in the employee table
objRS.Open "SELECT COUNT(*) from Employee" , objDB



Msgbox "There are " & objRS.Fields(0).Value & " records in the employee table."



' destroy the objects
Set objDB = Nothing
Set objRS = Nothing

How to Modular Automation Framework Checklist for the Smoke Testing

Re-usability – Develop a robust function library to be used across the projects and within the application.

Robustness – Develop a robust test suite that can be easily used for testing the application in different environments e.g. development, testing and production.

Portability – To ensure easy installation of the suite in different environments.

Modularity – Develop modular scripts to ensure maintainability, scalability and readability of the scripts.

Scalability - Scalable scripts which can be upgraded/ enhanced.

Maintainability – The approach should be such where in major effort goes in to the planning and developing the scripts where as least possible effort is required to maintain the same.

Data Driven Testing – To perform positive and negative tests using data driven scripts. To achieve this, we need to a checklist for Automation Framework Planning:

Identify the Scenarios / Test Cases for Smoke – 6 Identified Done
Execute the Scenarios / Test Cases Manually at least 5 times - Done
Get the Scenarios approved from QA Manager / Product Manager / Client - Done

Create the Folder Structure – Done, C:\AST
Create the shared object repository - Done
Identify the Actions for the approved scenarios – Done with 8 Actions
Create test data (take inputs from the manual testing team / SME’s) - Done
Generate the Actions / Action library by hard coding the data – 8 reusable created, 0-pending
Separate the data from the Actions / Reusable – Done
Integrate / call the Actions in the main test - Done
Execute & debug the Actions / Reusable - Done
Get the Actions reviewed by the lead / manager / client - Done
Create the AOM - Done
Use Environment Variables - Done –Build in, user defined Functions
Schedule the Smoke Test - Done

QTP 11.0: New features of QTP 11.0

How To Make Career In QTP: How To Make Career In QTP: Download Free QTP 11

New features in QTP 11.0:-

XPath and CSS based object identification
Identify objects not only using normal object identification but with XPath and CSS identifier properties. A much awaited and a killer feature

Good Looking and Enhanced Results ViewerThe new improved results viewer provides an executive summary page with summary data, pie charts and statistics for both the current and previous runs and a quick link to the previous run results.

Easy Regular Expressions
You can now create reg ex with the help of syntax hints. Regular Expression Evaluator is available to test regular expressions that you have created. Good One.

Now identify objects not only in relation to each other but in relation to neighboring objects.
With this feature, QTP 11 has moved beyond the unreliability of ordinal identifiers. Objects identified with ordinal identifiers are good only as long as they maintain their relative positions with respect to each other in the new build of application. In case if this position changes or gets interchanged, ordinal identifiers may go for a toss.
HP has now introduced Visual Relation Identifier.

A visual relation identifier is a set of definitions that enable you to identify the object in the application according its neighboring objects in the application. You can select neighboring objects that will maintain the same relative location to your object, even if the user interface design changes. You define visual relations in the Visual Relation Identifier dialog box, which is accessible from the local or shared object repository, and from the Object Properties dialog box.

Load Function Libraries at Run Time
With the help of LoadFunctionLibrary statement. You can now load a function library when a step runs instead of at the beginning of a run session.

Test Your GUI and UI-Less Application Functionality in One TestSince QTP is integrated with Service Test, you can now test your GUI and non-GUI based apps in a single run.

Record SupportFor FireFox is now available.

Much Awaited Log Tracking is available now
QTP 11 is capable of receiving Java or .NET log framework messages from your application which can then be embedded in the run results.

Embed/Run Javascript in web pagesYou can use the new EmbedScript/EmbedScriptFromFile and RunScript/RunScriptFromFile functions to embed JavaScripts in all loaded browser pages. You can use these scripts to perform operations on, or retrieve data from, the browser pages in your application.

Manage Test DataImproved test data management when integrated with Quality Center

Web 2.0 Toolkit Applications SupportQTP 11 now supports Web 2.0 Toolkit Applications out-of-the-box similar to any other add-ins.

Automatically Parameterize StepsYou can instruct QTP 11 to automatically parameterize test steps at the end of record session.

Silverlight Add-inTo test objects in Silverlight 2 and Silverlight 3 applications. [After installation, Silverlight Add-in is displayed in the Add-in Manager as a child add-in under the WPF Add-in]

Extend WPF and Silverlight SupportYou can use WPF and Silverlight Add-in Extensibility SDK to develop support for testing third-party and custom WPF and Silverlight controls that are not supported out-of-the-box

How To Make Career In QTP: Download Free QTP 11

How To Make Career In QTP: Download Free QTP 11

we should change the QTP version yet, i was working with QTP 10.0. today i got mail from client for upgarding the version 10.0 to 11.0

so please download the QTP v 11.0 and start working on the same. and please let me know if any question/ suggestion for the same.

Friday, January 28, 2011

QTP Interview Questions and answers

How To Make Career In QTP: QTP Interview Questions IBM

Q. How can i check the properties of an object in an application without using checkpoints? For Example how will you check whether a button is enabled?
Answer: GetROProperty method is used to retrieve the properties of the object in an application.It is very useful method and can be used to retrieve almost any of the property that can be seen while spying the object with object spy. For Example‘To get whether button is enabled or not.

Val = Browser("QA Friends").Page("QA Friends"). WebButton("Login"). GetROProperty("disabled")

‘To get whether a checkbox is on or off.

Val =Browser("QA Friends").Page("QA Friends").WebCheckBox("Test").GetROProperty("Value")


Q. How can I modify the properties values of test objects in Object Repository during runtime?

A. You can use SetTOProperty method of test object.Object(description).SetTOProperty Property, Value - The values of test object properties are used to identify the objects. Sometimes the properties of the object in the application change dynamically. For example text of a link in a webpage is the username used to login to that page.Text property is used by test object to identify the link. So in order to identify the actual object we can manipulate the value of “text” property of link using SetTOProperty.



Q. How do you synchronize your scripts in QTP?

A. For waiting until navigation of web page completes we can use Sync method. For waiting until an object appears we can use Exist method. For waiting until a property of object changes we can use WaitProperty method. You can set browser navigation timeout in: Click Test > Settings menu Select web tab in Test Settings window. Enter the timeout in Browser Navigation Timeout text box. You can set global object synchronization timeout in: Click Test > Settings menu Select Run tab in Test Settings window. Enter the timeout in Object Synchronization Timeout text box.

QTP Interview Questions IBM

1 Can I use recovery scenario without using recovery scenario wizard?


2. What is the actual difference in Text/Text Area checkpoint. (Explain in detail with proper example)


3. Code for reading the data of a particular cell from an external excel file using COM.


4. Can I use datatable of Action1 in the Action2.


5. Can I import a excel sheet in Action1 datatable? How?


6. How to use regular expression in DP. (I don't have any Object Repository in my test)


7. What are pros and cons of DP?

for Technical interviews:

http://no1tutorial.com/

learn step by step technologies:


http://no1tutorial.com/

QTP Certification

How To Make Career In QTP: QTP Certification: HP0-M39


the online websites of HP and also from the prometric centers who guide the procedure for the examination. Infact, the prometric centers acts as the site for clearing the examinations.

You need to register your names at the site for Hp certificate registration and receive a online voucher via payment on net. Else you can also contact your nearby prometric centre for applying for the examination. The cost of the certification is $150. There is a compulsory paper which is more like a initial cutoff for the certification. Despite this paper there are two optional papers which the candidate needs to clear in order to complete the certification. These papers can be selected as per the candidate choices.

HP has aliased with a third party team for the certification. So whenever, you register for the examination, you will receive a Prometric ID which needs to be entered during the examination. It is required to maintain the security regarding the ID to avoid any discrepancies. Last date for applying for the examination is 16th January 2010.

Links

http://www.softwaretestingstuff.com/2008/11/hp-qtp-certification-hp-m016-practice.html
http://www.softwaretestingstuff.com/2008/11/hp-qtp-certification-hp-m016-practice_21.html
http://www.softwaretestingstuff.com/2008/11/hp-qtp-certification-hp-m016-practice_22.html
http://www.softwaretestingstuff.com/2008/11/hp-qtp-certification-hp-m016-practice_149.html
http://quicktesthp.blogspot.com/2008/07/qtp-certification-practice-questions.html




Read more here: http://entrance-exam.net/qtp-certification-papers/#ixzz1CK4JSHtZ

What is difference between VBScript and VBA?

for Technical interviews:

http://no1tutorial.com/

learn step by step technologies:


http://no1tutorial.com/

What is difference between VBScript and VBA?


VBScript is a subset of Visual Basic for Applications, but there are still many differences:


VBScript doesn't have a debugger like Visual Basic or you can say that VBScript does not provide any debugging features. you'll resort to using lots of message boxes, instead.


Unlike Visual Basic and Visual Basic for Applications, in which the developer can define the data type of a variable in advance, all variables in VBScript are variants.


There is no intergrated development environment for VBScript that parallels the IDE for Visual Basic and Visual Basic for Applications.


Because variables are untyped and code is not complied, all external objects instantiated in VBScript code are neccessarily late-bound. This has a number of implications. First, late binding typically entails a substantial performance penalty in comparison to early binding. Second, while the properties and methods of early-bound objects can ve examined in Visual Basic or hosted VBA environments using the Object Browser, this is not the case with late-bound objects. Finally, the help facilities available for early-bound objects in VB and VBA (like Auto List Members and Auto Quick Info) are not available, making syntax errors more likely and ready access to good documentation all the more neccessary.

Download Free QTP 11

Please click on the below link for downloading QTP 11.0:-

https://h10078.www1.hp.com/cda/hpdc/navigation.do?action=downloadBinStart&caid=21691&cp=54_4000_100&zn=bto&filename=T6510FAE

Thanks,
for Technical interviews:

http://no1tutorial.com/

learn step by step technologies:


http://no1tutorial.com/

Sunday, January 23, 2011

How to retrieve data from excel sheet??

Function CopyrowfromExcel(strpath, Location, strTCRefval)

Dim arr(52)

Sheet=Location

Datatable.AddSheet Sheet

Set ObjectExcelApp = CreateObject("Excel.Application")

'Handling the Run time errors

On Error Resume Next

Err.Clear

Set ObjWorkbook=ObjectExcelApp.Workbooks.open (strpath)

Set ObjExcelSheet=ObjectExcelApp.worksheets(Trim(Sheet))

Rowscount=ObjExcelSheet.usedrange.rows.count

Columncount=ObjExcelSheet.usedrange.columns.count

'Below statements take column headers from external excel file andadd sameheaders to datatable

'Confirm there should not be any column header in the QTP datasheet

For j=1 to Columncount

ColumnHeader=ObjExcelSheet.cells(1, j).value

DataTable.GetSheet(Sheet).AddParameter ColumnHeader, ""

Next

'Below statements take desired row values and update in datatable

Flag=0

For k=1 to Rowscount

'Here I assume that first row always 'TCRef'.

strTCRef=ObjExcelSheet.cells(k, 1)

Friday, January 21, 2011

How to Compare two Word documents ??

How To Make Career In QTP: How to Extract all words from Word document ??

Dim Doc1, Doc2, oWord, oCompared
Doc1= "C:\Test1.doc"
Doc2= "C:\Test2.doc"

set oWord = createobject("Word.Application")
oWord.Visible =true

set oCompared = oWord.Documents.Open(Doc2)
oCompared.Compare(Doc1)
oCompared.Close

How to Extract all words from Word document ??

How To Make Career In QTP: How to Convert Word document to html/pdf ??

retrieves the number of words in the document.
Dim oWord, Doc, currentDocument
Doc = "C:\Test1.docx"
Set oWord = CreateObject("Word.Application")
oWord.DisplayAlerts = 0
oWord.Documents.Open Doc
Set currentDocument = oWord.Documents(1)

Dim nWords, n
nWords = currentDocument.Words.count
Print "Number of Words: " & nWords

For n = 1 to nWords
Print currentDocument.Words(n)
Next
currentDocument.Close
Set currentDocument = Nothing
oWord.Quit
Set oWord = Nothing

How to Convert Word document to html/pdf ??

ConvertDOCtoHTMLPDF("C:\Test1.docx","Pdf")
ConvertDOCtoHTMLPDF("C:\Test1.docx","html")
  
Function ConvertDOCtoHTMLPDF(SrcFile, Format)
   Dim fso, oFile, FilePath, myFile
   Set fso = CreateObject( "Scripting.FileSystemObject" )
   Set oFile = fso.GetFile(SrcFile)
   FilePath = oFile.Path
    
   Dim oWord
   Set oWord = CreateObject( "Word.Application" )
   oWord.Documents.Open FilePath
   If ucase(Format) = "PDF" Then
       myFile = fso.BuildPath (ofile.ParentFolder ,fso.GetBaseName(ofile) & ".pdf")
       oWord.Activedocument.Saveas myfile, 17
   elseIf ucase(Format) = "HTML" Then
       myFile = fso.BuildPath (ofile.ParentFolder ,fso.GetBaseName(ofile) & ".html")
       oWord.Activedocument.Saveas myfile, 8
   End If
   oWord.Quit
   Set oWord = Nothing
   Set fso = Nothing
   Set oFile = Nothing
End Function

Wednesday, January 19, 2011

How To Make Career In QTP: How can we launch QTP ??

How To Make Career In QTP: How to count checked checkboxes in QTP

Different ways to launch your application are mentioned below:

1) SystemUtil.Run

SystemUtil.Run ( FileName, Parameters, Path, Operation )
FileName - The name of the file you want to run.
Parameters - If the specified FileName is an executable file, use the Parameters argument to specify any parameters to be passed to the application.
Path - The default directory of the application or file.
Operation - The action to be performed. If this argument is blank (""), the open operation is performed.
The following operations can be specified for the operation argument of the SystemUtil.Run method:
open - Opens the file specified by the FileName parameter. The file can be an executable file, a document file, or a folder. Non-executable files are open in the associated application.
edit - Launches an editor and opens the document for editing. If the FileName argument does not specify an editable document file, the statement fails.
explore - Explores the folder specified by the FileName argument.
find - Initiates a search starting from the specified folder path.
print - Prints the document file specified by the FileName argument. If the specified file is not a printable document file, the statement fails.
Example:SystemUtil.Run "D:\My Music\Breathe.mp3","","D:\My Music\Details","open"

2) InvokeApplication

This command is now mainly used for the backward compatability ie to use with the lower versions(below QTP 6.0) of QTP.

InvokeApplication("Full URL as Parameter")
Example:InvokeApplication "C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.yahoo.com"

3) VBscript to invoke application

1. Create a "WScript.shell" object.
2. Use the "run" object to launch the application. If the path to your executable contains spaces, use Chr(34) to ensure the path is contained within double quotes.
3. When done, set the shell object to nothing to release it.

Example:
Dim oShellSet oShell = CreateObject ("Wscript.shell")'
Example 1 - run a batch file:oShell.run "F:\jdk1.3.1\demo\jfc\SwingSet2.bat"'
Example 2 - run a Java jar file:oShell.run "java -jar F:\jdk1.3.1\demo\jfc\SwingSet2\SwingSet2.jar"'
Example 3 - launch Internet Explorer:oShell.Run Chr(34) & "C:\Program Files\Internet Explorer\IEXPLORE.EXE" & Chr(34)Set oShell = Nothing

4) Trivial but useful method

If nothing works out you might try this

You can use the Start -> Run dialog of Windows.
1. Add the Windows Start button to the Object Repository using the "Add Objects" button in Object Repository dialog.
2. Open the Run dialog (Start -> Run), and learn the "Open" edit field and the "OK" button into the Object Repository.
3. Switch to the Expert View, and manually add the lines to open the Run dialog.
Example:Window("Window").WinButton("Button").ClickWindow("Window").Type("R")
4. Manually enter the lines to enter the information to launch the application, and click the "OK" button of the Run dialog.

Example:
Dialog("Run").WinEdit("Open:").Type "c:\WINNT\system32\notepad.exe"
Dialog("Run").WinButton("OK").Click

QTP For Beginners: regular Expression

How To Make Career In QTP: QTP For Bignners

A regular expression is a string that describes or matches a set of strings. It is often called a pattern as it describes set of strings.

Given underneath is one of the most widely used and ever confused BackLash character. The remaining expressions are serialized below that.

Using the Backslash Character
A backslash (\) instructs QuickTest to treat the next character as a literal character, if it is otherwise a special character. The backslash (\) can also instruct QuickTest to recognize certain ordinary characters as special characters. For example, QuickTest recognizes \n as the special newline character.
For example:
w matches the character w
\w is a special character that matches any word character including underscore
For example, in QTP, while entering the URL of a website,
http://mercurytours.mercuryinteractive.com
The period would be mistaken as an indication of a regular expression. To indicate that the period is not part of a regular expression, you would enter it as follows:
mercurytours\.mercuryinteractive\.com Note: If a backslash character is used before a character that has no special meaning, the backslash is ignored. For example, \z matches z.

Expressions & Explanation
Special characters and sequences are used in writing patterns for regular expressions. The following describes the characters and sequences that can be used.


\
Marks the next character as either a special character or a literal. For example, "n" matches the character "n". "\n" matches a newline character. The sequence "\\" matches "\" and "\(" matches "(".

^
Matches the beginning of input.

$
Matches the end of input.

*
Matches the preceding character zero or more times. For example, "zo*" matches either "z" or "zoo".

+
Matches the preceding character one or more times. For example, "zo+" matches "zoo" but not "z".

?
Matches the preceding character zero or one time. For example, "a?ve?" matches the "ve" in "never".

.
Matches any single character except a newline character.

(pattern)
Matches pattern and remembers the match. The matched substring can be retrieved from the resulting Matches collection, using Item [0]...[n]. To match parentheses characters ( ), use "\(" or "\)".

xy
Matches either x or y. For example, "zwood" matches "z" or "wood". "(zw)oo" matches "zoo" or "wood".

{n}
n is a nonnegative integer. Matches exactly n times. For example, "o{2}" does not match the "o" in "Bob," but matches the first two o's in "foooood".

{n,}
n is a nonnegative integer. Matches at least n times. For example, "o{2,}" does not match the "o" in "Bob" and matches all the o's in "foooood." "o{1,}" is equivalent to "o+". "o{0,}" is equivalent to "o*".

{n,m}
m and n are nonnegative integers. Matches at least n and at most m times. For example, "o{1,3}" matches the first three o's in "fooooood." "o{0,1}" is equivalent to "o?".

[xyz]
A character set. Matches any one of the enclosed characters. For example, "[abc]" matches the "a" in "plain".

[^xyz]
A negative character set. Matches any character not enclosed. For example, "[^abc]" matches the "p" in "plain".

[a-z]
A range of characters. Matches any character in the specified range. For example, "[a-z]" matches any lowercase alphabetic character in the range "a" through "z".

[^m-z]
A negative range characters. Matches any character not in the specified range. For example, "[m-z]" matches any character not in the range "m" through "z".

\b
Matches a word boundary, that is, the position between a word and a space. For example, "er\b" matches the "er" in "never" but not the "er" in "verb".

\B
Matches a non-word boundary. "ea*r\B" matches the "ear" in "never early".

\d
Matches a digit character. Equivalent to [0-9].

\D
Matches a non-digit character. Equivalent to [^0-9].

\f
Matches a form-feed character.

\n
Matches a newline character.

\r
Matches a carriage return character.

\s
Matches any white space including space, tab, form-feed, etc. Equivalent to "[ \f\n\r\t\v]".

\S
Matches any nonwhite space character. Equivalent to "[^ \f\n\r\t\v]".

\t
Matches a tab character.

\v
Matches a vertical tab character.

\w
Matches any word character including underscore. Equivalent to "[A-Za-z0-9_]".

\W
Matches any non-word character. Equivalent to "[^A-Za-z0-9_]".

\num
Matches num, where num is a positive integer. A reference back to remembered matches. For example, "(.)\1" matches two consecutive identical characters.

\n
Matches n, where n is an octal escape value. Octal escape values must be 1, 2, or 3 digits long. For example, "\11" and "\011" both match a tab character. "\0011" is the equivalent of "\001" & "1". Octal escape values must not exceed 256. If they do, only the first two digits comprise the expression. Allows ASCII codes to be used in regular expressions.

\xn
Matches n, where n is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For example, "\x41" matches "A". "\x041" is equivalent to "\x04" & "1". Allows ASCII codes to be used in regular expressions.

Friday, January 14, 2011

QTP Interview Questions and answers

How To Make Career In QTP: QTP Interview Questions and answers

• Import and Export of files.
• Random testing of 500 test cases.
• Invoking of application
• Opening notepad in QTP &Writing of Test Result in Notepad.
• Merging of Two Repositories
• Data file / Verification of data file when file is not available in local system.
• Business process component / Types and usage.
• Opening of notepad in QTP to write and execute the coding.
• How to find local host name using QTP
• How to handle exception when data table is not available in local host system or Path is not correct (Explain Statement with example)
• Runtime dynamic settings.
• Script generated after applying database check point.
• Script generated at the time of setting runtime property.
• Types of exception handling and script for that.
• Scripting

What is Recovery Scenario???

What are Recover Scenarios?

While executing your scripts you may get some UNEXPECTED/UNPREDICTABLE errors. (like printer out of paper). To "recover" the test (and continue running) from these unexpected errors you use Recovery Scenarios.
Next question arises,
When to use "on error resume next" or programmatic handling of errors VS Recovery Scenarios ?
If you can predict that a certain event may happen at a specific point in your test or component, it is recommended to handle that event directly within your test or component by adding steps such as If statements or optional steps or "on error resume next", rather than depending on a recovery scenario. Using Recovery Scenarios may result in unusually slow performance of your tests.They are designed to handle a more generic set of unpredictable events which CANNOT be handled programmatically.
For Example:
A recovery scenario can handle a printer error by clicking the default button in the Printer Error message box.
You cannot handle this error directly in your test or component, since you cannot know at what point the network will return the printer error. You could try to handle this event in your test or component by adding an If statement immediately after the step that sent a file to the printer, but if the network takes time to return the printer error, your test or component may have progressed several steps before the error is displayed. Therefore, for this type of event, only a recovery scenario can handle it.
I would not go into details of how to create files and how to define them since they are fully covered in QTP Documentation. Mercury QuickTest Professional User's Guide > Working with Advanced Testing Features > Defining and Using Recovery Scenarios >
What constitute Recovery Scenarios?
A recovery scenario consists of the following:


•Trigger Event. The event that interrupts your run session. For example, a window that may pop up on screen, or a QTP run error.


•Recovery Operations. The operations to perform to enable QTP to continue running the test after the trigger event interrupts the run session. For example, clicking an OK button in a pop-up window, or restarting Microsoft Windows.


•Post-Recovery Test Run Option. The instructions on how QTP should proceed after the recovery operations have been performed, and from which point in the test QTP should continue, if at all. For example, you may want to restart a test from the beginning, or skip a step entirely and continue with the next step in the test.

Recovery scenarios are saved in recovery scenario files having the extension .rs. A recovery scenario file is a logical collection of recovery scenarios, grouped according to your own specific requirements.
Is there a method to programmatically call them?
By default, QTP checks for recovery triggers when an error is returned during the run session. You can use the Recovery object's method to force QTP to check for triggers after a specific step in the run session.
For a complete list go to QTP Documentation > Quick Test Advanced References > Quick Test Automation > Recovery Object

How to call external file and application in QTP

There are various ways through with we can call files and applications in QTP. Below are the four very simple ways:

Method 1. Use "InvokeApplication" command - Invokes an executable application.

Note: In most situations, you should use a SystemUtil.Run statement to run applications or to open files in their default application. The InvokeApplication statement is supported primarily for backward compatibility.

Example:
The following example uses the InvokeApplication function to open Internet Explorer.

InvokeApplication "E:\Program Files\Plus!\Microsoft Internet\IEXPLORE.EXE".



Method 2. The use of "SystemUtil.Run" command - Runs a file or application.

When specifying a non-executable file, the file opens in the associated application.

Note: A SystemUtil.Run statement is automatically added to your test when you run an application from the Start menu or the Run dialog box while recording a test.

Tip: You can also use this method to perform operations on the specified file, similar to the usage of the Windows ShellExecute command.



You can directly run the windows applications by just giving the application name. No need to give complete path.

Example:

SystemUtil.Run “IEXPLORE.EXE”



Note – The difference between SystemUtil.Run and InvokeApplication is – In SystemUtil.Run No need to give complete path for windows shell applications. But in InvokeApplication you need to give path for each application.



Example -
Open a Text File in the Default Text Application (Notepad)

Sub CloseDescendentProcesses_Example()
'The following example uses the Run method to open a file named type.txt
'in the default text application (Notepad). It then types "happy days",
'saves the file using shortcut keys, and then closes the application.

SystemUtil.Run "C:\type.txt", "", "", ""
Window("Text:=type.txt - Notepad").Type "happy days"
Window("Text:=type.txt - Notepad").Type micAltDwn & "F" & micAltUp
Window("Text:=type.txt - Notepad").Type micLShiftDwn & "S" & micLShiftUp
Window("Text:=type.txt - Notepad").Close

End Sub



Method 3. ExecuteFile function - Executing Externally-Defined Functions from Your QTP Test scripts.



If you decide not to associate a function library (any VBScript file) with a test, but do want to be able to call its functions, subroutines, and so forth from an action in your test or from another function library, you can do so by inserting an ExecuteFile statement in your action.

When you run your test, the ExecuteFile statement executes all global code in the function library making all definitions in the file available from the global scope of the action's script.



Note: You cannot debug a file that is called using an ExecuteFile statement, or any of the functions contained in the file. In addition, when debugging a test that contains an ExecuteFile statement, the execution marker may not be correctly displayed.

Tip: If you want to include the same ExecuteFile statement in every action you create, you can add the statement to an action template.



To execute an externally-defined function:

1. Create a VBScript file using standard VBScript syntax. For more information, see the Microsoft VBScript Language Reference (Help > QuickTest Professional Help > VBScript Reference > VBScript).
2. Store the file in any folder that you can access from the computer running your test.
3. Add an ExecuteFile statement to an action in your test using the following syntax:
ExecuteFile FileName

where FileName is the absolute or relative path of your VBScript file.

4. Use the functions, subroutines, and so forth, from the specified VBScript file as necessary in your action.



Method 4. The use of "WshShell.Exec" method - Runs an application in a child command-shell, providing access to the StdIn/StdOut/StdErr streams.

Remarks
The Exec method returns a WshScriptExec object, which provides status and error information about a script run with Exec along with access to the StdIn, StdOut, and StdErr channels. The Exec method allows the execution of command line applications only. The Exec method cannot be used to run remote scripts. Do not confuse the Exec method with the Execute method (of the WshRemote object).

Example
The following example demonstrates the basics of the Exec method.

[VBScript]
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec("calc")

Do While oExec.Status = 0
WScript.Sleep 100
Loop

WScript.Echo oExec.Status
[JScript]
var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("calc");

while (oExec.Status == 0)
{
WScript.Sleep(100);
}

WScript.Echo(oExec.Status);

Thursday, January 13, 2011

How to count checked checkboxes in QTP

Set a =Description.Create
a("html tag").value="INPUT"
a("micclass").value="WebCheckBox"
a("checked").value=0

Set b = Browser("Colony Rater 3.0").Page("Colony Rater 3.0").childobjects(a)
'If b = "ON" Then
c=b.count
'End IF
msgbox c

Wednesday, January 12, 2011

Download free QTP Framwork

If you want any type of framwork then mail me

shahadat.it786@gmail.com

There are mainly three components in the framwork like 1.Datatable 2.Scripts 3. Function Library
for Technical interviews:

http://no1tutorial.com/

learn step by step technologies:


http://no1tutorial.com/

QTP Certification: HP0-M39 Sample Question Paper

for Technical interviews:

http://no1tutorial.com/

learn step by step technologies:


http://no1tutorial.com/
Make Your Career in QTP: QTP Certification: HP0-M39

1. How can you add recordable or non-recordable operations to your test? (Select three.)
A. Use the Step Generator.
B. Insert through Keyword View.
C. Drag objects from the object repository.
D. Drag objects from the Active Screen.
E. Drag objects from Available Keywords.
F. Drag objects from the Data Table.
Answer: ABE

2. What is a QuickTest Professional test comprised of?
A. calls to actions
B. calls to actions (reusable only)
C. calls to QuickTest Professional tests
D. calls and copies of actions
Answer: A

3. Which names are used to identify the status of your application before and after your automated test executes? (Select two.)
A. initial condition
B. static state
C. end condition
D. down condition
E. done condition
Answer: AC

4. During the planning phase, you decide to create multiple actions that can be combined and reused to achieve testing goals. Which element is critical for identifying the actions to be recorded and how to combine them?
A. input data
B. parameters
C. initial and end conditions
D. visual cues
Answer: C

5. What are the default add-ins installed with QuickTest Professional? (Select three.)
A. .NET
B. ActiveX
C. HTML
D. Web
E. Java
F. OCX
G. Visual Basic
Answer: BDG

6. Which Quick Test Professional View Option will show you the repositories associated with each action?
A. Resources
B. Information
C. Script Repository
D. Active Screen
Answer: A

7. Where can you reset the add-in manager if it does not display when you launch QuickTest Professional?
A. General Options
B. Run Options
C. Test Properties
D. Test Settings
Answer: A

8. You set your Record and Run settings to Record, and then run a test on any open browser. Which applications will be recorded? (Select two.)
A. Firefox
B. Safari
C. Silverlight
D. Chrome
E. Internet Explorer
Answer: AE
for Technical interviews:

http://no1tutorial.com/

learn step by step technologies:


http://no1tutorial.com/

Make Your Career in QTP: QTP For Bignners

Make Your Career in QTP: QTP For Bignners

The QTP (QuickTest Professional) testing process consists of the following main phases:

1. Analyzing your application
The first step in planning your test is to analyze your application to determine your testing needs.



What are your application's development environments (for example Web, Java, or .NET)? You will need load QTP add-ins for these environments to enable QTP to identify and work with the objects in your application.
What business processes and functionality do you want to test? To answer this, think about the various activities that customers perform in your application to accomplish specific tasks.
Consider how to divide these business processes into smaller units. You will be creating actions based on these tasks. Smaller and more modular actions make your tests easier to read and follow, and help ease maintenance in the long run.
At this stage, you can already begin creating test skeletons and adding actions to them.


2. Preparing the testing infrastructure
Based on your testing needs, you determine what resources are required and create these resources, accordingly. Resources include shared object repositories containing test objects (which are representations of the objects in your application), function libraries containing functions that enhance QTP functionality, and so on.



You also need to configure QTP settings so that QTP will perform the tasks you need, such as displaying a results report every time you run a test.



3. Building your tests and adding steps to them
After the testing infrastructure is ready, you can begin building your tests. You can create one or more empty tests and add actions to them to create the testing skeletons. You associate your object repositories with the relevant actions, and associate your function libraries with the relevant tests, so that you can insert steps using keywords. You may also need to configure test preferences at this point.



4. Enhancing your test
Inserting checkpoints into your test lets you search for a specific value of a page, object, or text string, which helps you determine whether your application is functioning correctly.

Broadening the scope of your test, by replacing fixed values with parameters, lets you check how your application performs the same operations with multiple sets of data.

Adding logic and conditional or loop statements enables you to add sophisticated checks to your test.



5. Debugging, running, and analyzing your test
You debug a test to ensure that it operates smoothly and without interruption. After the test is working correctly, you run it to check the behaviour of your application. While running, QTP opens the application and performs each step in your test.

You examine the test results to pinpoint defects in your application.

6. Reporting defects
If you have Quality Center installed, you can report the defects you discover to a database. Quality Center is the HP test management solution

QTP Testing Process

Make Your Career in QTP: QTP Interview Questions: QTP Practice Questions for interviews
1. What are the Features & Benefits of Quick Test Pro(QTP)..?

1. Key word driven testing
2. Suitable for both client server and web based application
3. VB script as the script language
4. Better error handling mechanism
5. Excellent data driven testing features



2. How to handle the exceptions using recovery scenario manager in QTP?

You can instruct QTP to recover unexpected events or errors that occurred in your testing environment during test run. Recovery scenario manager provides a wizard that guides you through the defining recovery scenario. Recovery scenario has three steps
1. Triggered Events
2. Recovery steps
3. Post Recovery Test-Run

3. How to handle the exceptions using recovery scenario manager in QTP?

You can instruct QTP to recover unexpected events or errors that occurred in your testing environment during test run. Recovery scenario manager provides a wizard that guides you through the defining recovery scenario. Recovery scenario has three steps:
1. Triggered Events
2. Recovery steps
3. Post Recovery Test-Run



3. What is the use of Text output value in QTP?

Output values enable to view the values that the application talks during run time. When parameterized, the values change for every iteration. Thus by creating output values, we can capture the values that the application takes for each run and output them to the data table.



4. How to use the Object spy in QTP?

There are two ways to Spy the objects in QTP
1) Thru file toolbar
---In the File Tool Bar click on the last toolbar button (an icon showing a person with hat).
2) Thru Object repository Dialog
---In Object repository dialog click on the button “object spy...”
In the Object spy Dialog click on the button showing hand symbol.
The pointer now changes in to a hand symbol and we have to point out the object to spy the state of the object
If at all the object is not visible or window is minimized then Hold the Ctrl button and activate the required window to and release the Ctrl button.



5. What is the file extension of the code file & object repository file in QTP?

File extension of
-- Per test object rep: - filename.mtr
-- Shared Object rep: - filename.tsr
-- Codes file extension id: - script.mts



6. Explain the concept of object repository & how QTP recognizes objects?

Object Repository: displays a tree of all objects in the current component or in the current action or entire test (depending on the object repository mode you selected).
We can view or modify the test object description of any test object in the repository or to add new objects to the repository.
Quick test learns the default property values and determines in which test object class it fits. If it is not enough it adds assistive properties, one by one to the description until it has compiled the unique description. If no assistive properties are available, then it adds a special Ordinal identifier such as objects location on the page or in the source code.



7. What are the properties you would use for identifying a browser & page when using descriptive programming?

"Name" would be another property apart from "title" that we can use.
OR
We can also use the property "micClass".
Ex: Browser("micClass:=browser").page("micClass:=page")....



8. What are the different scripting languages you could use when working with QTP?

Visual Basic (VB), XML, JavaScript, Java, HTML



9 Give example where you have used a COM interface in your QTP project?

COM interface appears in the scenario of front end and back end. for eg:if you r using oracle as back end and front end as VB or any language then for better compatibility we will go for an interface. of which COM will be one among those interfaces. Create object creates handle to the instance of the specified object so that we program can use the methods on the specified object. It is used for implementing Automation(as defined by Microsoft).



10. Few basic questions on commonly used Excel VBA functions.

Common functions are:
Coloring the cell
Auto fit cell
Setting navigation from link in one cell to other
Saving



11. Explain the keyword create object with an example.

Creates and returns a reference to an Automation object
Syntax: CreateObject(servername.typename [, location])
Arguments
SERVERNAME: Required. The name of the application providing the object
TYPENAME: Required. The type or class of the object to create
LOCATION: Optional. The name of the network server where the object is to be created



12. Explain in brief about the QTP Automation Object Model.

Essentially all configuration and run functionality provided via the QTP interface is in some way represented in the QTP automation object model via objects, methods, and properties. Although a one-on-one comparison cannot always be made, most dialog boxes in QTP have a corresponding automation object, most options in dialog boxes can be set and/or retrieved using the corresponding object property, and most menu commands and other operations have corresponding automation methods. You can use the objects, methods, and properties exposed by the QTP automation object model, along with standard programming elements such as loops and conditional statements to design your program.



13. How to handle dynamic objects in QTP?

QTP has a unique feature called Smart Object Identification/recognition. QTP generally identifies an object by matching its test object and run time object properties. QTP may fail to recognize the dynamic objects whose properties change during run time. Hence it has an option of enabling Smart Identification, wherein it can identify the objects even if their properties changes during run time.
Check this out-
If QuickTest is unable to find any object that matches the recorded object description, or if it finds more than one object that fits the description, then QuickTest ignores the recorded description, and uses the Smart Identification mechanism to try to identify the object.
While the Smart Identification mechanism is more complex, it is more flexible, and thus, if configured logically, a Smart Identification definition can probably help QuickTest identify an object, if it is present, even when the recorded description fails.
The Smart Identification mechanism uses two types of properties:
Base filter properties—the most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a Web link's tag was changed from to any other value; you could no longer call it the same object. Optional filter properties—other properties that can help identify objects of a particular class as they are unlikely to change on a regular basis, but which can be ignored if they are no longer applicable.



14. What is a Run-Time Data Table? Where can I find and view this table?

In QTP, there is data table used, which is used at runtime.
-In QTP, select the option View->Data table.
-This is basically an excel file, which is stored in the folder of the test created, its name is Default.xls by default.



15. How does Parameterization and Data-Driving relate to each other in QTP?

To data drive we have to parameterize i.e. we have to make the constant value as parameter, so that in each iteration (cycle) it takes a value that is supplied in run-time data table. Through parameterization only we can drive a transaction (action) with different sets of data. You know running the script with the same set of data several times is not suggestible, & it's also of no use.



16. What is the difference between Call to Action and Copy Action.?

Call to Action: The changes made in Call to Action, will be reflected in the original action (from where the script is called).But where as in Copy Action, the changes made in the script, will not affect the original script (Action)



17. Discuss QTP Environment.

QuickTest Pro environment using the graphical interface and Active Screen technologies - A testing process for creating test scripts, relating manual test requirements to automated verification features - Data driving to use several sets of data using one test script.



18. Explain the concept of how QTP identifies object.

During recording QTP looks at the object and stores it as test object. For each test object QT learns a set of default properties called mandatory properties, and look at the rest of the objects to check whether this properties are enough to uniquely identify the object. During test run, QT searches for the run time objects that match with the test object it learned while recording.



19. Differentiate the two Object Repository Types of QTP.

Object repository is used to store all the objects in the application being tested. 2 types of object repository per action and shared. In shared repository only one centralized repository for all the tests, where as in per action for each test a separate per action repository is created.



20. What the differences are and best practical application of each.

Per Action: For Each Action, one Object Repository is created.
Shared: One Object Repository is used by entire application

21. Explain what the difference between Shared Repository and Per_Action Repository

Shared Repository: Entire application uses one Object Repository, that similar to Global GUI Map file in WinRunner
Per Action: For each Action, one Object Repository is created, like GUI map file per test in WinRunner



22. Have you ever written a compiled module? If yes tell me about some of the functions that you wrote.

I used the functions for capturing the dynamic data during runtime. Function used for Capturing Desktop, browser and pages.

23. What projects have you used WinRunner on? Tell me about some of the challenges that arose and how you handled them.

PBS: WR fails to identify the object in GUI. If there is a non standard window object cannot recognize it, we use GUI SPY for that to handle such situation.



24. Can you do more than just capture and playback?

I have done dynamically capturing the objects during runtime in which no recording, no playback and no use of repository is done AT ALL.
-It was done by the windows scripting using the DOM (Document Object Model) of the windows.



25. How to do the scripting. Are there any inbuilt functions in QTP as in QTP-S.? What is the difference between them? How to handle script issues?

Yes, there's an in-built functionality called "Step Generator" in Insert->Step->Step Generator -F7, which will generate the scripts as u enter the appropriate steps.

26. What is the difference between check point and output value.

I would like to add some stuff to Kalpana's comments.
It is as follows:-
An outPut value is a value captured during the test run and entered in the run-time but to a specified location.
EX:-Location in Data Table [Global sheet / local sheet]



27. IF we use batch testing the result shown for last action only in that how can i get result for every action.

u can click on the icon in the tree view to view the result of every action.



28. How the exception handling can be done using QTP

It can be done using the Recovery Scenario Manager which provides a wizard that guides you through the process of defining a recovery scenario. FYI The wizard could be accessed in QTP> Tools-> Recovery Scenario Manager.......



29. How many types of Actions are there in QTP?

There are three kinds of actions:
Non-reusable action—an action that can be called only in the test with which it is stored, and can be called only once.
Reusable action—an action that can be called multiple times by the test with which it is stored (the local test) as well as by other tests.
External action—a reusable action stored with another test. External actions are read-only in the calling test, but you can choose to use a local, editable copy of the Data Table information for the external action.



30. I want to open a Notepad window without recording a test and I do not want to use SystemUtil.Run command as well. How do I do this?



U can still make the notepad open without using the record or System utility script, just by mentioning the path of the notepad "( i.e., where the notepad.exe is stored in the system) in the "Windows Applications Tab" of the "Record and Run Settings window. Try it out.

QTP Interview Questions and answers

Make Your Career in QTP: Make Your Career in QTP: QTP Interview Questions: QTP Practice Questions for interviews

1. What are the Features & Benefits of Quick Test Pro(QTP)..?

1. Key word driven testing
2. Suitable for both client server and web based application
3. VB script as the script language
4. Better error handling mechanism
5. Excellent data driven testing features



2. How to handle the exceptions using recovery scenario manager in QTP?

You can instruct QTP to recover unexpected events or errors that occurred in your testing environment during test run. Recovery scenario manager provides a wizard that guides you through the defining recovery scenario. Recovery scenario has three steps
1. Triggered Events
2. Recovery steps
3. Post Recovery Test-Run

3. How to handle the exceptions using recovery scenario manager in QTP?

You can instruct QTP to recover unexpected events or errors that occurred in your testing environment during test run. Recovery scenario manager provides a wizard that guides you through the defining recovery scenario. Recovery scenario has three steps:
1. Triggered Events
2. Recovery steps
3. Post Recovery Test-Run



3. What is the use of Text output value in QTP?

Output values enable to view the values that the application talks during run time. When parameterized, the values change for every iteration. Thus by creating output values, we can capture the values that the application takes for each run and output them to the data table.



4. How to use the Object spy in QTP?

There are two ways to Spy the objects in QTP
1) Thru file toolbar
---In the File Tool Bar click on the last toolbar button (an icon showing a person with hat).
2) Thru Object repository Dialog
---In Object repository dialog click on the button “object spy...”
In the Object spy Dialog click on the button showing hand symbol.
The pointer now changes in to a hand symbol and we have to point out the object to spy the state of the object
If at all the object is not visible or window is minimized then Hold the Ctrl button and activate the required window to and release the Ctrl button.



5. What is the file extension of the code file & object repository file in QTP?

File extension of
-- Per test object rep: - filename.mtr
-- Shared Object rep: - filename.tsr
-- Codes file extension id: - script.mts



6. Explain the concept of object repository & how QTP recognizes objects?

Object Repository: displays a tree of all objects in the current component or in the current action or entire test (depending on the object repository mode you selected).
We can view or modify the test object description of any test object in the repository or to add new objects to the repository.
Quick test learns the default property values and determines in which test object class it fits. If it is not enough it adds assistive properties, one by one to the description until it has compiled the unique description. If no assistive properties are available, then it adds a special Ordinal identifier such as objects location on the page or in the source code.



7. What are the properties you would use for identifying a browser & page when using descriptive programming?

"Name" would be another property apart from "title" that we can use.
OR
We can also use the property "micClass".
Ex: Browser("micClass:=browser").page("micClass:=page")....



8. What are the different scripting languages you could use when working with QTP?

Visual Basic (VB), XML, JavaScript, Java, HTML



9 Give example where you have used a COM interface in your QTP project?

COM interface appears in the scenario of front end and back end. for eg:if you r using oracle as back end and front end as VB or any language then for better compatibility we will go for an interface. of which COM will be one among those interfaces. Create object creates handle to the instance of the specified object so that we program can use the methods on the specified object. It is used for implementing Automation(as defined by Microsoft).



10. Few basic questions on commonly used Excel VBA functions.

Common functions are:
Coloring the cell
Auto fit cell
Setting navigation from link in one cell to other
Saving



11. Explain the keyword create object with an example.

Creates and returns a reference to an Automation object
Syntax: CreateObject(servername.typename [, location])
Arguments
SERVERNAME: Required. The name of the application providing the object
TYPENAME: Required. The type or class of the object to create
LOCATION: Optional. The name of the network server where the object is to be created



12. Explain in brief about the QTP Automation Object Model.

Essentially all configuration and run functionality provided via the QTP interface is in some way represented in the QTP automation object model via objects, methods, and properties. Although a one-on-one comparison cannot always be made, most dialog boxes in QTP have a corresponding automation object, most options in dialog boxes can be set and/or retrieved using the corresponding object property, and most menu commands and other operations have corresponding automation methods. You can use the objects, methods, and properties exposed by the QTP automation object model, along with standard programming elements such as loops and conditional statements to design your program.



13. How to handle dynamic objects in QTP?

QTP has a unique feature called Smart Object Identification/recognition. QTP generally identifies an object by matching its test object and run time object properties. QTP may fail to recognize the dynamic objects whose properties change during run time. Hence it has an option of enabling Smart Identification, wherein it can identify the objects even if their properties changes during run time.
Check this out-
If QuickTest is unable to find any object that matches the recorded object description, or if it finds more than one object that fits the description, then QuickTest ignores the recorded description, and uses the Smart Identification mechanism to try to identify the object.
While the Smart Identification mechanism is more complex, it is more flexible, and thus, if configured logically, a Smart Identification definition can probably help QuickTest identify an object, if it is present, even when the recorded description fails.
The Smart Identification mechanism uses two types of properties:
Base filter properties—the most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a Web link's tag was changed from to any other value; you could no longer call it the same object. Optional filter properties—other properties that can help identify objects of a particular class as they are unlikely to change on a regular basis, but which can be ignored if they are no longer applicable.



14. What is a Run-Time Data Table? Where can I find and view this table?

In QTP, there is data table used, which is used at runtime.
-In QTP, select the option View->Data table.
-This is basically an excel file, which is stored in the folder of the test created, its name is Default.xls by default.



15. How does Parameterization and Data-Driving relate to each other in QTP?

To data drive we have to parameterize i.e. we have to make the constant value as parameter, so that in each iteration (cycle) it takes a value that is supplied in run-time data table. Through parameterization only we can drive a transaction (action) with different sets of data. You know running the script with the same set of data several times is not suggestible, & it's also of no use.



16. What is the difference between Call to Action and Copy Action.?

Call to Action: The changes made in Call to Action, will be reflected in the original action (from where the script is called).But where as in Copy Action, the changes made in the script, will not affect the original script (Action)



17. Discuss QTP Environment.

QuickTest Pro environment using the graphical interface and Active Screen technologies - A testing process for creating test scripts, relating manual test requirements to automated verification features - Data driving to use several sets of data using one test script.



18. Explain the concept of how QTP identifies object.

During recording QTP looks at the object and stores it as test object. For each test object QT learns a set of default properties called mandatory properties, and look at the rest of the objects to check whether this properties are enough to uniquely identify the object. During test run, QT searches for the run time objects that match with the test object it learned while recording.



19. Differentiate the two Object Repository Types of QTP.

Object repository is used to store all the objects in the application being tested. 2 types of object repository per action and shared. In shared repository only one centralized repository for all the tests, where as in per action for each test a separate per action repository is created.



20. What the differences are and best practical application of each.

Per Action: For Each Action, one Object Repository is created.
Shared: One Object Repository is used by entire application

21. Explain what the difference between Shared Repository and Per_Action Repository

Shared Repository: Entire application uses one Object Repository, that similar to Global GUI Map file in WinRunner
Per Action: For each Action, one Object Repository is created, like GUI map file per test in WinRunner



22. Have you ever written a compiled module? If yes tell me about some of the functions that you wrote.

I used the functions for capturing the dynamic data during runtime. Function used for Capturing Desktop, browser and pages.

23. What projects have you used WinRunner on? Tell me about some of the challenges that arose and how you handled them.

PBS: WR fails to identify the object in GUI. If there is a non standard window object cannot recognize it, we use GUI SPY for that to handle such situation.



24. Can you do more than just capture and playback?

I have done dynamically capturing the objects during runtime in which no recording, no playback and no use of repository is done AT ALL.
-It was done by the windows scripting using the DOM (Document Object Model) of the windows.



25. How to do the scripting. Are there any inbuilt functions in QTP as in QTP-S.? What is the difference between them? How to handle script issues?

Yes, there's an in-built functionality called "Step Generator" in Insert->Step->Step Generator -F7, which will generate the scripts as u enter the appropriate steps.

26. What is the difference between check point and output value.

I would like to add some stuff to Kalpana's comments.
It is as follows:-
An outPut value is a value captured during the test run and entered in the run-time but to a specified location.
EX:-Location in Data Table [Global sheet / local sheet]



27. IF we use batch testing the result shown for last action only in that how can i get result for every action.

u can click on the icon in the tree view to view the result of every action.



28. How the exception handling can be done using QTP

It can be done using the Recovery Scenario Manager which provides a wizard that guides you through the process of defining a recovery scenario. FYI The wizard could be accessed in QTP> Tools-> Recovery Scenario Manager.......



29. How many types of Actions are there in QTP?

There are three kinds of actions:
Non-reusable action—an action that can be called only in the test with which it is stored, and can be called only once.
Reusable action—an action that can be called multiple times by the test with which it is stored (the local test) as well as by other tests.
External action—a reusable action stored with another test. External actions are read-only in the calling test, but you can choose to use a local, editable copy of the Data Table information for the external action.



30. I want to open a Notepad window without recording a test and I do not want to use SystemUtil.Run command as well. How do I do this?



U can still make the notepad open without using the record or System utility script, just by mentioning the path of the notepad "( i.e., where the notepad.exe is stored in the system) in the "Windows Applications Tab" of the "Record and Run Settings window. Try it out.

Thanks,
Shahadat Khan

VB Scripting in QTP: VB Script functions

Make Your Career in QTP: VB Scripts

InStr Returns the position of the first occurrence of one string within another. The search begins at the first character of the string



InStrRev Returns the position of the first occurrence of one string within another. The search begins at the last character of the string



LCase Converts a specified string to lowercase



Left Returns a specified number of characters from the left side of a string



Len Returns the number of characters in a string



LTrim Removes spaces on the left side of a string



RTrim Removes spaces on the right side of a string




Trim Removes spaces on both the left and the right side of a string




Mid Returns a specified number of characters from a string




Replace Replaces a specified part of a string with another string a specified number of times




Right Returns a specified number of characters from the right side of a string




Space Returns a string that consists of a specified number of spaces




StrComp Compares two strings and returns a value that represents the result of the comparison




String Returns a string that contains a repeating character of a specified length




StrReverse Reverses a string




UCase Converts a specified string to uppercase




Other Functions



Function



CreateObject Creates an object of a specified type



Eval Evaluates an expression and returns the result



GetLocale Returns the current locale ID




GetObject Returns a reference to an automation object from a file




GetRef Allows you to connect a VBScript procedure to a DHTML event on your pages




InputBox Displays a dialog box, where the user can write some input and/or click on a button, and returns the contents




IsEmpty Returns a Boolean value that indicates whether a specified variable has been initialized or not




IsNull Returns a Boolean value that indicates whether a specified expression contains no valid data (Null)




IsNumeric Returns a Boolean value that indicates whether a specified expression can be evaluated as a number




IsObject Returns a Boolean value that indicates whether the specified expression is an automation object




LoadPicture Returns a picture object. Available only on 32-bit platforms




MsgBox Displays a message box, waits for the user to click a button, and returns a value that indicates which button the user clicked




RGB Returns a number that represents an RGB color value




Round Rounds a number




ScriptEngine Returns the scripting language in use




ScriptEngineBuildVersion Returns the build version number of the scripting engine in use




ScriptEngineMajorVersion Returns the major version number of the scripting engine in use




ScriptEngineMinorVersion Returns the minor version number of the scripting engine in use




SetLocale Sets the locale ID and returns the previous locale ID




TypeName Returns the subtype of a specified variable




VarType Returns a value that indicates the subtype of a specified variable

VB Scripts

for Technical interviews:

http://no1tutorial.com/

learn step by step technologies:


http://no1tutorial.com/
Scripting Conventions
1.1 Variable Naming Conventions
To enhance readability and consistency, use the following prefixes with descriptive names for variables in your code.

Subtype Prefix Example
Array arr arrCountry
Boolean bln blnFound
Byte byt bytRasterData
Currency cur curRate
Date (Time) dtm dtmStart
Double dbl dblTolerance
Enum enum enumWeekDays
Error err errOrderNum
Integer int intQuantity
Long lng lngDistance
Object obj objCurrent
Single sng sngAverage
String str strFirstName
The body of a variable or function name should use mixed case and should be as descriptive as necessary. In addition, function names should begin with a verb, such as strNameArray or fncCloseDialog.
For frequently used or long terms, standard abbreviations are recommended to help keep name length reasonable. In general, variable names greater than 32 characters can be difficult to read. When using abbreviations, make sure they are consistent throughout the entire script. For example, randomly switching between Cnt and Count within a script or set of scripts may lead to confusion.


1.2 Object Naming Conventions
The following table lists recommended conventions for web objects:
Object Type Prefix Example
Browser bro broBrowser
Dialog dlg dlgFileOpen
Frame fra fraLanguage
Horizontal Scroll Bar hsb hsbVolume
Image img imgIcon
Label lbl lblHelpMessage
Link lnk lnkLogout
Page pag pagHome
SwfWindow swin swinSchoolDetails
SwfButton sbtn sbtnAddress
SwfCheckBox schk schkPrimaryClass
SwfComboBox scbo scboCountry
SwfEdit sedt sedtPassword
SwfLabel slbl slblContactDetails
SwfListView slstv slstvSchoolDetails
SwfObject sobj sobjAddressControl
SwfStatusBar ssb ssbSchool
SwfTable stbl stblGridControl
SwfToolBar stb stbStatusBar
ViewLink vlnk vlnkPreferences
Vertical Scroll Bar vsb vsbRate
WebArea ware wareRemarks
WebButton wbtn wbtnOk
WebCheckBox wchk wchkHobbies
WebComboBox wcbo wcboEnglish
WebEdit wedt wedtUsername
WebElement emt wemtCurrenty
WebFile wfil wfilTestData
WebList wlst wlstCountry
WebRadioGroup wrgr wrgrGender
WebTable wtbl wtblSalesInfo
Window win winNotepad
WinButton winbtn winbtnYes
WinCheckBox winchk winchkHobbies
WinComboBox wincbo wincboEnglish
WinEdit winedt winedtSalesBox
WinListView winlstv winlstvSchoolDetails
WinObject winobj winobjDescriptionBar

• Block Comments


‘*******************************************************************************
‘ Name:
' Author:
‘ Description:
' Pre-Requisites: Input file abcd.txt is in dir z:\
‘ Input files: Input.xls

' History:
' Date Version No. Author Description
------ -------------- --------- --------------
'
'
' *******************************************************************************

Thanks,
Shahadat Khan

for Technical interviews:

http://no1tutorial.com/

learn step by step technologies:


http://no1tutorial.com/

Learn QTP : Descriptive Programming

for Technical interviews:

http://no1tutorial.com/

learn step by step technologies:


http://no1tutorial.com/
Make Your Career in QTP: Descriptive Programming

Introduction
Descriptive programming has become the technique of choice for many QTP test developers. We can talk about its advantages and disadvantages all day, but here, we’ll only discuss the concepts and come up with our own idea of what it does better, and what it doesn’t :). This is going to be a very quick refresher before we move on to its everyday application by completing an end-to-end testcase.
The idea behind descriptive programming is for automation developers to instruct QTP which properties they would like to use to identify an object, instead of having QTP to choose them itself. If done correctly, this can help create robustness in scripts, ultimately requiring less maintenance-time and more development time.
Let’s begin.
But wait, before we really begin, we must understand QTP’s Object Spy. It is an inbuilt tool that enlists all of the test-object and runtime-object properties. These properties are different for different types for objects. For example, an image has a property called ‘file name’ whereas a listbox doesn’t. Instead, a listbox has a special ‘all items’ property whereas the image doesn’t. This discussion will be limited to the usage test-object properties to identify objects. Below are 2 snapshots of the Object Spy:

Object Spy Icon

Object Spy Window
Now, let’s open www.Google.com and use the object spy to retrieve all properties of the search box:

Object Spy: WebEdit Properties
Notice the image above. The editbox has a HTML TAG property with its corresponding value ‘INPUT’. This means, the editbox takes some input from the user – which is true because we do set some value in it! It also has a ‘MAX LENGTH’ property, with a value of ‘2048′. This means, you can enter a maximum of 2048 characters in it (the best source to see all of the Test-Object properties of objects is the QTP help itself). Below you will see an editBox which can contain a maximum of 9 characters:
Test maxLength:

You can really use all these properties to identify this editbox, but, do we really need to use all of them? No. That is the most important idea behind descriptive programming – we only use what we need. Below is how we write descriptions for objects:
ObjectClassName("property:=value", "property:=value")

' ofcourse we're not limited to only 2 properties. We can write more:
ObjectClassName("property:=value", "property:=value", "property:=value")
Above, ObjectClassName (in Web applications) can be Browser, Page, Frame, WebEdit, Image etc. Properties come from the left column the ObjectSpy column whereas values are in the right column. We can include as many properties as we want, but in reality, we only need to add a few to uniquely identify the object. Knowing which properties should suffice to uniquely identify can object will come from experience and practice. Below is a description I created for this editbox (WebEdit):
'ObjectClassName( "property1:=value1", "property2:=value2" )
WebEdit( "name:=q", "html tag:=INPUT" )
I already mentioned the HTML TAG and its value INPUT above. We’ve also added a new property/value here: ‘name:=q’. Is this enough to uniquely identify the object? Yes. But is it enough to make our script work? No, sadly its not.. and that is because, we haven’t yet created descriptions for its parent objects: Browser & Page. Below are the snapshots of the spied browser and page objects:

Object Spy: Browser Properties

Object Spy: Page Properties
Browser description:
'ObjectClassName( "property1:=value1" )
Browser( "title:=Google" )
Page description:
Page( "title:=Google" )
Now, we will connect all these descriptions and form a hierarchical tree:
Browser("title:=Google").Page("title:=Google").WebEdit("name:=q","html tag:=INPUT")
You might wonder why I have omitted the WebTable below the Page and above the WebEdit object. In practice, we can also skip the Page object to identify the WebEdit. But, why did I skip the WebTable after all!? When you experiment more with DP, you will discover that some objects are embedded in many WebTables, and it will become cumbersome if we were to include all WebTables in the hierarchy to get to the object of interest (thanks to the person who thought that will be a terrible idea!). Example of the previously mentioned scenario:

Object Spy: Multiple WebTables
To complete the statement above, we will add an event. In QTP, events can be described as actions on target objects. For example, a WebEdit has a ‘Set’ event. we use the ‘Set’ method of a WebEdit to set a value:
Browser("title:=Google").Page("title:=Google").WebEdit("name:=q","html tag:=INPUT").Set "DP"
Set is a QTP event to put in a value in the edit box. Different objects have different events. For example: an Image has a ‘Click’ event associated with it.
This, we did without using Object Repository. The same concept applies to all objects regardless of what your environment is. We perform actions on child objects by accessing their object hierarchies. Let’s complete the above example by searching for our keywords (use the spy again on the search button):
Browser("title:=Google").Page("title:=Google").WebEdit("name:=q", "html tag:=INPUT").Set "DP"
Browser("title:=Google").Page("title:=Google").WebButton("name:=Google Search").Click
This is how the same code will look like if we had recorded this process:
Browser("Google").Page("Google").WebEdit("q").Set "DP is great"
Browser("Google").Page("Google").WebButton("Google Search").Click
These properties are now stored in QTP’s Object Repository (OR). There is another way we can create object descriptions, which is done by setting a reference:
' Creating Browser description
' "title:=Google"
Set oGoogBrowser = Description.Create
oGoogBrowser( "title" ).value = "Google"

' Creating Page description
' "title:=Google"
Set oGoogPage = Description.Create
oGoogPage( "title" ).Value = "Google"

'* Creating WebEdit description
' "html tag:=INPUt", "name:=q"
Set oGoogWebEdit = Description.Create
oGoogWebEdit( "html tag" ).Value = "INPUT"
oGoogWebEdit( "name" ).Value = "q"
Once we do the above, we can use this descriptions in our script:
Browser(oGoogBrowser).Page(oGoogPage).WebEdit(oGoogWebEdit).Set "DP is great"
The only time I use this technique is to retrive object collections through ChildObjects (we will discuss this in the coming tutorials).
Let’s do another example. Again, we will use Google, but instead of setting a value, we will click an object. You can choose any Link on the page; I chose the link ‘Images’:

Object Spy: Google Images Link
'ClassName("property:=value").ClassName("propert1:=value").ClassName("property:=value").Event
Browser("title:=Google").Page("title:=Google").Link("innertext:=Images", "html tag:=A").Click
This time, instead of ‘Set’ we used ‘Click’. Following is a list of events we perform on Web objects:
Object Event
Image Click
WebButton Click
WebCheckBox Set
WebEdit Set
WebElement Click
WebList Select
WebRadioGroup Select