Thursday, May 21, 2009

3.QTP QUESTIONS FOR INTERVIEW

1.Difference between QTP 9.2 and QTP 9.5?

The difference that most people will notice is the fact that Checkpoints are now stored in the object repository. The major enhancement in QTP9.5 from earlier versions is you can create your own QTP add-in. When your add-in is loaded, Quicktest will recognize objects as you defined.

Here QTP 9.5 features
1)All in one quicktest installations; (while installing it shows all external add-ins along with CD ,purchase only )Licence Key.
2)Process Guidence ;(For Beginners how the  Automation Process with step by step.)
3)Available keywords ;(In a test what are the Public functions,Private functions,Test object available we can view)
4)Drag and Drop from OR; (we generate the script automatically by droping the Test object from OR in avaialble Keywords)
5)maintence runmode;(For updating the script statements ,adding new statements,for commenting old statements)
6)Testing the Power builder app
7)Accelarated the SAP Testing.
8)In OR check points and outputvalues on Testobjects.
9)Existing checkpoint on Testobjects.
10)Available resources (Function Lib,Recovery scenarios,External,Reusable,Non reusable actions)
etc.....

 

2.New in qtp 9.5

  Maintenance Run Mode :

Repair your test on the fly, this will assists you to  adding the steps or uodating the object proprties in OR on the fly.i.e. if your object properties are changed after a new build, you just run the Maintenance Run Mode and update your OR according to that on the fly.

  Process Guidance :

This is little more than more accessible help files. Maybe this is good for when you are first learning to record a test, but it doesn’t seem to add much utility.

  Flow Pane

  Available Keywords Pane

All Test Objects and functions in one handy location.Rapid test development with drag & drop.Object repository now also supports drag & drop

  Resources Pane :

All resources associated with the test. You can see all your library file in this pane

  Missing Resources Pane

  Relative Path Helper

  Improved Bitmap Checkpoint

  Web Extensibility :

1.Anyone can add support for new web controls

2.Rapid development in JavaScript

3.Solid infrastructure supplied by the Web add-in

4.Extensibility objects are first class citizens

 5.Built-in toolkit: ASPAjax

  Tabbed browsing :

Tabs identified as separate browsers.Same test compatible with tabbed and non tabbed browsers.

  New Technologies :

1.PowerBuilder

2. Oracle − Forms 10 −Apps 12

3.StingRay Objective Grid 10, 114. PeopleSoft 9.0•

4.New Terminal Emulator versions

5.NET 3.5 (beta)

  New environments  :

1.Windows Vista 64 bit

2. Eclipse 3.2, 3.3

3.Record on SWT

4. Firefox 3.0

5.Netscape 9

For i=1 to Ubound(listarray,1)
datatable.GetSheet(”Action1″).SetCurrentRow i
For j=1 to Ubound(listarray,2)
listarray(i,j) = datatable.Value (j,”Action1″)

MEANING

For i=1 to Ubound(listarray,1)’Ubound is the upper boundary (assume length) of the array. so in this stmt it is trying to get the ubound of the 2nd dimention( as u know the arrays can have any number of dimentions)

datatable.GetSheet(”Action1″).SetCurrentRow i’This stmt is to set the current row of the datatable sheet “Action1″ to content in the variable i

For j=1 to Ubound(listarray,2)’ This statement also holds the same info explained in first Stmt except it gets the Ubound value from 2 dimention

listarray(i,j) = datatable.Value (j,”Action1) ‘ This stmt is setting the value comes from column number present in j of datatable sheet “Action1″

3.HOW WE BUILT FRAME WORK

·                     Maintenance Run Mode

·                     Process Guidance

·                     All in one installation

·                     Flow Pane

·                     Available Keywords Pane

·                     Resources Pane

·                     Missing Resources Pane

·                     Relative Path Helper

·                     Checkpoint Management

·                     Improved Bitmap Checkpoint

·                     BPT

·                     Web Extensibility

·                     Tabbed browsing

·                     New Technologies

·                     New environments

4.Difference with QTP 9.5 TO QTP 10

You can upgrade qtp9.5 to qtp 10 without uninstalling.

IntelliSense functionality is improved.

Design and functionality of a debugger pane is improved.

Maintenance Run mode now includes new object identification Solutions.

Added Control for editing and Managing Actions in Automation Scripts.

An new look for dialog boxes.

An improved web Add-in Extensibility

Delphi ADD-IN enables to test WLC Delphi controls

test result can be exported to msdoc and pdf format.you can develop their own logarithm to compare bit map check points.You can centrally manage your work items and To DO tasks in the To Do Pane, which enables you to create and control self-defined tasks and view a compiled set of the TODO comments from your tests, associated function libraries and components.

LoadAndRunAction statement helps you load and run an action only when the step runs so that these actions are not loaded each time you open a test.Integration abilities are there.You can use the file> Save Test with Resources command to save a standalone, local copy of your test with all associated resources files and any called actions. This perks up portability.

 

5.Types of frame work? What is that?
It depends upon the project we will  use

1)linear 2) Datadriven 3)Keyword 4) Functional/Modula 5)
Hybrid Frame work
1) linear:- is nothing but record and play back 
2)Datadriven:- Parametersing the data for different input 
and getting different outputs
3)keyword:-is nothing but creating  s/w structure like 
scripts, OR, test data, Recovery scenarios, log files, 
Library files ets
4)Functional/Modular:-Each and Individual Functions can be 
scripted mostly used for BPT scripts
5)Hybrid:-Combination of the above any two Frame works 

 

6.Explain about Hybrid Framework

Hybrid Framework is a combination of Keyword and Data-
Driven framework.This framewok is very useful and used in 
most of the projects.

 

7.What expansion of "MIC" in MICPASS (TEST ReportPAGE)
MIC Stands for Microsoft integer constant

 

8.How to invoke Mozilla from QTP thru VB Script

InvokeApplication "executable file path of mozilla"
    Or
SystemUtil.Run "executable file path of mozilla"
 
mention the executable file path of mozilla in double  qutoes.
 
The main difference between InvokeApplication and 
SystemUtil.Run is we can open what ever file you want like the files with extension .txt,.xl,.doc,.doc.. using  SystemUtil.Run ,but using InvokeApplication we can open the 
files with a extension .exe

 

9.Descriptive programming script to find the number of edit boxes in a login window in flights reservation (windows application only not web). 2. Using descriptive programing, how do you handle changing URLs. 

 
Set obj_edit = description.Create
obj_edit("nativeclass").value = "Edit"
Set EditDesc = dialog("Login").ChildObjects(obj_edit)
 
msgbox "Number of Edit Fields : "& EditDesc.count
 
For i = 0 to EditDesc.count - 1
               EditDesc1 = (EditDesc(i).getROProperty("Attached Text"))
               msgbox EditDesc1
 
Next

 

10.Whenever we use GETROPROPERTY function.
"GETROPROPERTY"  capture the properties  of the object at the script  running postion

Syntax:getroproperty(browser("Siva").page("Siva").object ("objectname","value"))

 

11.How qtp identifies objects of application.
Using object repository,qtp identifies object of an application

or QTP identifies the object in the Application by LogicalName and Class

 

12.In a webpage how to check the dynamic links that re changing regularly?( without using regular expressions.)
We can use index ..also if we know to what name the link is changing we can use settoproperty..

 

13.How to handle Dynamically changing Objects in QTP?
If the object is dynamically changing then we can set the property of that object with

 set to property.propertyname.propertyvalue

 

14.What is the advantage of merging tool in QTP 9.2? 

The advantages of the merging the two OR's is to remove the redundancy of objects in the OR, which will improve the performance of QTP. When you have multiple shared object repositories that contain test objects from the same area of your application, it may be useful to combine those test objects into a single object repository for easier maintenance.

 

15. How we can do Batch testing in QTP?
A special tools add wis Qtp In QTP tool not like Win Runner

1.Goto Tool/Option/Run
2.Click on checkbox{Allow other..}
Apply
3.Goto Start Menu/Prog/Qtp/Tool/Testbatch Run
Batch/Add
Select script and open dat u wana run
Goto Batch?run
 
 

16.How to convert non-reusable action into reusable action in QTP?

Access Menu Edit >> Action >> Action Properties
 
The general tab of action properties has a check box for Reusable action

 

17.Batch testing in how many ways u perform in QTP
Batch Testing can perform in 2 ways :

1.Run Action name ,one iteration we can use this command and we can run number tests one by one.The exit of first action is the base of second action.
eg: Run Test1, one iteration
    Run Test2, one iteration
 
2.Test batch runner Tool.

 

18.What are default add-ins in qtp?
1. Windows

2. VB
3. Web
4. Active X

 

19.What is the purpose of .vbs file?
.vbs stands for the files of type Visual Basic Script..vbs files can be executed on  windows platform by double clicking that file or executed from command prompt by

WHS  'Windows Host Server' which comes default with any windows OS. Test scripts in QTP or any functions can be saved as .vbs files.

 

20.What is the difference between CVS and VSS? Are you store QTP SCRIPT In VSS OR CVS? Where you store QTP Script?
Both are configuration management tools. We maintain all scripts in the form of frame work in the tool. Total your frame work store in the configuration tools with version numbers when ever you want you can open.

 

21.What  is the function ? How to do bach testing in the test director using maual testing procedure?

function Example:   
functin add()
x=1
f=1
c=x+f
add=c
end function

 

22.What is the exact difference bet function and action in QTP

Action -> Action is nothing but a script written for certain function point .
Action types : Non-reusable , reusable , external
Action may return multiple values.Action requires its own object repository( requires objects) Actions concept is restricted to QTP only ..
 
Function -> It consists of Set of statements written to achieve a particular task.
Function returns one value.Functions concept is used all programming languages, scripting languages.
Types of functions in QTP->Built in, Local Script, Library functions.
WIthout using objects Functions can be written ( in descriptive programming )

 

 23. Where we save all scripts in the QTP Answer
Scripts in QTP will be stored in  .mts extenstion

 

24.What is descriptive programming in QTP? How can be done?

Whenever QTP records any action on any object of an application, it adds some description on how to recognize that object to a repository of objects called object repository. QTP cannot take action on an object until unless its object description is in the Object Repository. But descriptive programming provides a way to perform action on objects which are not in Object repository. Visit: http://www.onestopsoftwar etesting.com/ One Stop Software Testing A Practical Approach to Software Testing.

Descriptive programming can be done in 2 ways:

Static: We provide set of properties & values, that describe the object ,directly.

Dynamic: We have to add a collection of properties and  values to a description object & then provide the statement with the description objects name.

Static is easier but Dynamic provides more power, efficiency & flexibility.

25.How to write descriptive programming, Give an example with program by taking objects like textbox, listbox, password e.tc

This is the way to write the descriptive progrDialog("Text:= Login").WinEdit("Attached Text:= Agent Name:").Set "asdfg"Dialog("Text:= Login").WinEdit("Attached Text:= Password:").SetSecure "mercury"Dialog("Text:= login").WinButton("Text:= OK").Click
 

26.I want to use QTP to test web application in that application there is one menu like file and under that there are diff menus like create, new,open etc. so while recording if I click on new then it get recorded. but in new when I click on new then

Please write code like this..  Note: No need for OR
 Browser("" ).Page("").SelectMenu "File->Save"

Can u write a sample code of Descriptive progamming for yahoo login form?

Eg . CODE: Browser("title:=Yahoo! Photos*.*").page("title:=Yahoo! Photos*.*").WebEdit("name:=login").set "srinivas" Browser("title:=Yahoo! Photos*.*").page("title:=Yahoo! Photos*.*").WebEdit("name:=passwd").set "test"Browser("title:=Yahoo! Photos*.*").page("title:=Yahoo! Photos*.*").WebButton("name:=Sign In").click

System util object

SystemUtil Object allows you to open & close application by writing its code manually in the expert view of QTP.

Eg how to open and close the note pad using code.

Systemutil.Run”Notepad.exe”

Wait(3)

SystemUtil.CloseProcessByName(“Notepad.exe”)

In Last line we can also use

window(“title:=Untitled-Notepad”.Close

27.When and Why to use Descriptive programming?

Below are some of the situations when Descriptive Programming can be considered useful:

  1. The objects in the application are dynamic in nature and need special handling to identify the object. The best example would be of clicking a link which changes according to the user of the application, Ex. “Logout <>”.
  2. When object repository is getting huge due to the no. of objects being added. If the size of Object repository increases too much then it decreases the performance of QTP while recognizing a object.
  3. When you don’t want to use object repository at all. Well the first question would be why not Object repository? Consider the following scenario which would help understand why not Object repository

Scenario 1: Suppose we have a web application that has not been developed yet. Now QTP for recording the script and adding the objects to repository needs the application to be up, that would mean waiting for the application to be deployed before we can start of with making QTP scripts. But if we know the descriptions of the objects that will be created then we can still start off with the script writing for testing

 

Scenario 2: Suppose an application has 3 navigation buttons on each and every page. Let the buttons be “Cancel”, “Back” and “Next”. Now recording action on these buttons would add 3 objects per page in the repository. For a 10 page flow this would mean 30 objects which could have been represented just by using 3 objects. So instead of adding these 30 objects to the repository we can just write 3 descriptions for the object and use it on any page. 

  1. Modification to a test case is needed but the Object repository for the same is Read only or in shared mode i.e. changes may affect other scripts as well.
  2. When you want to take action on similar type of object i.e. suppose we have 20 textboxes on the page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 20 the Object repository would not be a good programming approach.

28.How to use Descriptive programming?

There are two ways in which descriptive programming can be used

  1. By creating properties collection object for the description.
  2. By giving the description in form of the string arguments.

1.      By creating properties collection object for the description.:To use this method you need first to create an empty description 

Dim obj_Desc ‘Not necessary to declare

Set obj_Desc = Description.Create 

Now we have a blank description in “obj_Desc”. Each description has 3 properties “Name”, “Value” and “Regular Expression”.

obj_Desc(“html tag”).value= “INPUT” 

When you use a property name for the first time the property is added to the collection and when you use it again the property is modified. By default each property that is defined is a regular expression. Suppose if we have the following description 

obj_Desc(“html tag”).value= “INPUT”

obj_Desc(“name”).value= “txt.*”

This would mean an object with html tag as INPUT and name starting with txt. Now actually that “.*” was considered as regular expression. So, if you want the property “name” not to be recognized as a regular expression then you need to set the “regularexpression” property as FALSE

 

      obj_Desc(“html tag”).value= “INPUT”

obj_Desc(“name”).value= “txt.*”

obj_Desc(“name”).regularexpression= “txt.*” 

This is how of we create a description. Now below is the way we can use it 

Browser(“Browser”).Page(“Page”).WebEdit(obj_Desc).set “Test” 

When we say .WebEdit(obj_Desc) we define one more property for our description that was not earlier defined that is it’s a text box (because QTPs WebEdit boxes map to text boxes in a web page).If we know that we have more than 1 element with same description on the page then we must define “index” property for the that descriptionConsider the HTML code given below:

Now the html code has two objects with same description. So distinguish between these 2 objects we will use the “index” property. Here is the description for both the object

For 1st textbox:

obj_Desc(“html tag”).value= “INPUT”

obj_Desc(“name”).value= “txt_Name”

obj_Desc(“index”).value= “0” 

For 2nd textbox:

obj_Desc(“html tag”).value= “INPUT”

obj_Desc(“name”).value= “txt_Name”

obj_Desc(“index”).value= “1”

Consider the HTML Code given below: 

 

We can use the same description for both the objects and still distinguish between both of them

obj_Desc(“html tag”).value= “INPUT”

obj_Desc(“name”).value= “txt_Name” 

When I want to refer to the textbox then I will use the inside a WebEdit object and to refer to the radio button I will use the description object with the WebRadioGroup object.

Browser(“Browser”).Page(“Page”).WebEdit(obj_Desc).set “Test” ‘Refers to the text box

Browser(“Browser”).Page(“Page”).WebRadioGroup(obj_Desc).set “Test” ‘Refers to the radio button

But if we use WebElement object for the description then we must define the “index” property because for a webelement the current description would return two objects.

Hierarchy of test description:When using programmatic descriptions from a specific point within a test object hierarchy, you must continue to use programmatic descriptions from that point onward within the same statement. If you specify a test object by its object repository name after other objects in the hierarchy have been described using programmatic descriptions, QuickTest cannot identify the object.For example, you can use Browser(Desc1).Page(Desc1).Link(desc3), since it uses programmatic descriptions throughout the entire test object hierarchy.You can also use Browser(”Index”).Page(Desc1).Link(desc3), since it uses programmatic descriptions from a certain point in the description (starting from the Page object description).However, you cannot use Browser(Desc1).Page(Desc1).Link(”Example1″), since it uses programmatic descriptions for the Browser and Page objects but then attempts to use an object repository name for the Link test object (QuickTest tries to locate the Link object based on its name, but cannot locate it in the repository because the parent objects were specified using programmatic descriptions). 

Getting Child Object:We can use description object to get all the objects on the page that matches that specific description. Suppose we have to check all the checkboxes present on a web page. So we will first create an object description for a checkbox and then get all the checkboxes from the page  

Dim obj_ChkDesc

 

Set obj_ChkDesc=Description.Create

obj_ChkDesc(“html tag”).value = “INPUT”

obj_ChkDesc(“type”).value = “checkbox” 

Dim allCheckboxes, singleCheckBox 

Set allCheckboxes = Browse(“Browser”).Page(“Page”).ChildObjects(obj_ChkDesc) 

For each singleCheckBox in allCheckboxes singleCheckBox.Set “ON” 

Next

The above code will check all the check boxes present on the page. To get all the child objects we need to specify an object description i.e. we can’t use the string arguments that will be discussed later in the 2nd way of using the programming description.

Possible Operation on Description Object:Consider the below code for all the solutions

Dim obj_ChkDesc 

Set obj_ChkDesc=Description.Create

obj_ChkDesc(“html tag”).value = “INPUT”

obj_ChkDesc(“type”).value = “checkbox”

 

29. How to get the no. of description defined in a collection?

    obj_ChkDesc.Count ‘Will return 2 in our case 

30. How to remove a description from the collection?

 obj_ChkDesc.remove “html tag” ‘would delete the html tag property from the collection  

 31. How do I check if property exists or not in the collection?

The answer is that it’s not possible. Because whenever we try to access a property which is not defined its automatically added to the collection. The only way to determine is to check its value that is use a if statement “if obj_ChkDesc(“html tag”).value = empty then”.

 

32.How to browse through all the properties of a properties collection?

 Two ways

1st:

For each desc in obj_ChkDesc

Name=desc.Name

Value=desc.Value

RE = desc.regularexpression

Next

2nd:

For i=0 to obj_ChkDesc.count - 1

Name= obj_ChkDesc(i).Name

Value= obj_ChkDesc(i).Value

RE = obj_ChkDesc(i).regularexpression

Next

 

  1. By giving the description in form of the string arguments.

You can describe an object directly in a statement by specifying property:=value pairs describing the object instead of specifying an object’s name. The general syntax is:

TestObject(”PropertyName1:=PropertyValue1″, “…” , “PropertyNameX:=PropertyValueX”)

 

TestObject—the test object class could be WebEdit, WebRadioGroup etc….

PropertyName:=PropertyValue—the test object property and its value. Each property:=value pair should be separated by commas and quotation marks. Note that you can enter a variable name as the property value if you want to find an object based on property values you retrieve during a run session. 

Consider the HTML Code given below: 

 

Now to refer to the textbox the statement would be as given below 

Browser(“Browser”).Page(“Page”).WebEdit(“Name:=txt_Name”,”html tag:=INPUT”).set “Test”

And to refer to the radio button the statement would be as given below

Browser(“Browser”).Page(“Page”).WebRadioGroup(“Name:=txt_Name”,”html tag:=INPUT”).set “Test”

If we refer to them as a web element then we will have to distinguish between the 2 using the index property 

Browser(“Browser”).Page(“Page”).WebElement(“Name:=txt_Name”,”html tag:=INPUT”,”Index:=0”).set “Test” ‘ Refers to the textbox

Browser(“Browser”).Page(“Page”).WebElement(“Name:=txt_Name”,”html tag:=INPUT”,”Index:=1”).set “Test” ‘ Refers to the radio button

 33.What is Document object Model?

Document Object Model(DOM):A platform- and language-independent standard object model for representing HTML or XML and related formats. For QTP’s sake, I would redefine it to make it simpler. DOM is a method for QTP engineers to access the source (IE –> View –> Source) of any webpage direct through VB Scripting.

34.When can we use DOM?
 One of the very important places you can use it is when a QTP web table checkpoint doesn’t show you the desired content in a cell. I mean the content in the cell is in a format that is not supported by the web table checkpoint. Another use can be when you want to access all the HTML tags used in a webpage. You can get the names, the innertext, innerHTML property of all these tags. The possibilities are endless.
35.How can we use DOM to access the source page?

We can access the source page of any webpage using .object notation.

37.How to Close QTP after execution 

Private Function CloseQTP        

    Set objWMIService = GetObject(”winmgmts:\\.\root\CIMV2″)     

       Set colProcess = objWMIService.ExecQuery (”Select * from Win32_Process Where Name = ‘QTPro.exe’”)     

       For Each objProcess in colProcess                      

  objProcess.Terminate()           

 Next          

  Set objWMIService = Nothing         

   Set colProcess = NothingEnd FunctionCall CloseQTP

38.How to specify the environment variables to be loaded when QTP is started?

You can either define individual values in the .vbs file or specify an environment file to load. Example:
Here is what the .vbs file could look like:

Dim App ‘As Application

‘ Launch QTP
Set App = CreateObject(”QuickTest.Application”)
App.Launch
App.Visible = True

‘ Load an INI file with user-defined parameters
App.Test.Environment.LoadFromFile “C:\Test_Params\environment_file1.ini”

‘ Set the value of a specific user-defined Environment variable
App.Test.Environment.Value(”newvariable”) = “new value”

As you can see from the example, the Environment variable file is actually an .ini file. The structure would be:

   [Environment]
   var1=value1
   var2=value2
   …

There are several other options and settings you can set using the Automation Object Model. You can find documentation on this feature in the Documentation section on the Customer Support website. You do need to use QuickTest Professional 6.5 in order to use the Automation Object Model.

39.What is the QuickTest Automation Object Model?

You can use the QuickTest Professional Automation Object Model to write programs that automate your QuickTest operations. The QuickTest Automation Object Model provides objects, methods, and properties that enable you to control QuickTest from another application.

The new QuickTest Professional Automation Object Model enables you to automate test management.

You can now control virtually every QuickTest feature and capability using the objects, methods and properties included in the QuickTest Professional Automation Object Model. Automation scripts make it easy to perform any QuickTest operation multiple times in multiple tests without having to open the QuickTest application, for example,

  • You can write a script that modifies the test object description properties in the Object Identification dialog box and performs an update run on all tests in a specified file folder.
  • After installing a new add-in, an automation script can associate this add-in to all relevant tests.
  • You can write an automation script to run a selected batch of tests. For each test, you can retrieve the associated add-ins list. Then, if the necessary add-ins are not already loaded, you can close QuickTest, load the necessary add-ins, reopen QuickTest, and run the test.
  • You can define your settings for a test in QuickTest, then click “Generate Script” in the Generate tab of the Test Settings dialog box to generate an automation script based on the current test settings. You can then apply those same settings automatically to multiple tests using the whole automation script or excerpts from the generated file.

Example:
You can create and run an automation program from Microsoft Visual Basic that loads the required add-ins for a test, starts QuickTest in visible or minimized mode, opens the test, configures settings that correspond to those in the Options, Test Settings, and Record and Run Settings dialog boxes, runs the test, and saves the test.

Creating automation programs:
The Properties tab of the Test Settings dialog box, the General tab of the Options dialog box, and the Object Identification dialog box each contain a “Generate Script” button. Clicking this button generates a automation script file (.vbs) containing the current settings from the corresponding dialog box.

You can run the generated script as is to open QuickTest with the exact configuration of the QuickTest application that generated the script, or you can copy and paste selected lines from the generated files into your own automation script.

Generating an automation script for QuickTest Professional options:
1. Go to Tools -> Options.
2. Select the General tab.
3. Click .
4. Save the script to the desired location.
5. Click to close the Options dialog.

Generating an automation script for test settings:
1. Go to Test -> Settings.
2. Select the Properties tab.
3. Click .
4. Save the script to the desired location.
5. Click to close the Test Settings dialog.

Generating an automation script for object identification settings:
1. Go to Tools -> Object Identification.
2. Click .
3. Save the script to the desired location.
4. Click to close the Object Identification dialog.

The QuickTest Automation Object Model Reference file is a help file that provides detailed descriptions, syntax information, and examples for the objects, methods, and properties in the QuickTest Automation Object Model.

When QuickTest Professional 6.5 is installed you can open the QuickTest Automation Object Model Reference from:

  • The QuickTest program folder (Start -> Programs -> QuickTest Professional -> Documentation -> Automation Object Model Reference)
  • The QuickTest Help menu (Help -> QuickTest Automation Object Model Reference)

40.How to Execute QTP script from Command Prompt using Automation Object Model?

In order to run QTP scripts on schedule, we can run them directly from command line.In order to do so we can make use of QTP Automation Object Model which can help us in automating QuickTest operations. Using the objects, methods, and properties exposed by the QuickTest automation object model, we can write scripts that configure QuickTest options and run tests instead of performing these operations manually using the QuickTest interface. 

In the following code we are trying to execute a QTP script called “Google_search” from command line. Let’s create a script in QTP and save it as Google_search.Write the following code in a vbs (VB Script) file as save it as demo.vbs

Dim qtApp ‘ Declare the Application object variable

Dim qtTest ‘ Declare a Test object variable

Dim qtResultsOpt ‘Declare a Run Results Options object variable

Set qtApp = CreateObject(”QuickTest.Application”) ‘ Create the Application object

qtApp.Launch ‘ Start QuickTest

qtApp.Visible = True ‘ Make the QuickTest application visible

qtApp.Open “C:\Documents and Settings\pwahi\Desktop\Google search“, True ‘ Open the test in read-only mode

‘ set run settings for the test

Set qtTest = qtApp.Test

qtTest.Run’ Run the test

WScript.StdOut.Write “Status is:” & qtTest.LastRunResults.Status ‘ Check the results of the test run

qtTest.Close ‘ Close the test

Set qtTest = Nothing ‘ Release the Test object

Set qtApp = Nothing ‘ Release the Application object

Now in order to execute QTP script from command line we have to execute the above created vbs file from command prompt which will in turn launch QTP, open the script, run it and will display the result in command prompt only. Open command prompt and write following code:

C:\Documents and Settings\pwahi\Desktop>cscript //nologo demo.vbs

And press enter

This command will execute the demo.vbs file which in turn launch QTP, open the script Google search, execute it and will display the result in QTP result file. We can also see the results in command prompt as shown below.

If the script passes the result is declared in command prompt as follows:

Status is: Passed

Some places where we can use AOM

This is a small list of places (but not limited to) where we can use AOM. Thumb Rule - Use it at any place where you find yourself doing repetitive tasks while using QTP.

  • AOM can come handy when you have a large no of scripts to be uploaded to QC. A simple script can save you hours of manual work!
  • Use AOM to initialize QTP options and settings like add-ins etc.
  • You can use AOM to call QTP from other application: For ex: You can write a macro for calling QTP from excel.

Caution: AOM should be used outside of QTP and not within the script (during playback). Though there is no harm using it inside but some of the AOM statements might fail.

41.How to write AOM scripts?

You need to understand that the very root of QT AOM is Application Object. Every automation script begins with the creation of the QuickTest "Application" object. Creating this object does not start QuickTest. It simply provides an object from which you can access all other objects, methods and properties of the QuickTest automation object model.You can create only one instance of the Application object. You do not need to recreate the QuickTest Application object even if you start and exit QuickTest several times during your script. Once you have defined this object you can then successfully work and perform operations on other objects given in Quick Test Pro > Documentation > QuickTest Automation Reference.
For ex: Let us connect to TD QC using AOM and open a script "qtp_demo"

Dim qt_obj 'Define a Quick Test object
qt_obj = CreateObject("Quick Test.Application")
' Instantiate a QT Object. It does not start Q

42.How can we generate script for exception handler in QTP? Explanation with  script ?

We can generate the script for exceptions using recovery scenario manager

or with in the script as well.
1)using recovery script get the properties of the exception object and add it in the resources by naming the exception. We can create the recovery scenario in the options and add it in the resources of the file menu.when generating the script after the exception comes in type wait() please specify some umber like 10 or any value in() so that it will wait and then add the recovery scenario over there ad continue with the script
2)while writing

the script with out using the recovery scenario use when event occurs goto step umber and add the recovery scenario by what ever the type of framework that you are using.

43.How to perform Cross platform testing and Cross browser testing using QTP? Explain giving some example?

Cross Platform Testing:
There is a provision of getting the
Operating system in QTP by using the Built in Environment. Eg. Platform = Environment("OS"). Then based on the Platform you need to call the actions which you recorded on that particular platform.
Cross Browser Testing:
First get the type of
browser you are using: Eg. Browser("Core Values").GetROProperty("version")
This will give you internet explorer 6 or netscape 5. Based on this value you call the actions which are relavent to that browser.

44.What is the scope of a variable in an action?

Depends on where the variable is defined. If the variable is defined in action it is available to that action only.

45.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.
ex: Browser("name:="xxx"").page("name:="xxxx"").....
OR

We can also use the property "micClass".
ex: Browser("micClass:=browser").page("micClass:=page")....

46.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 orginal action( from where the script is called).But where as in Copy Action , the changes made in the script ,will not effect the original script(Action)

47.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

48.Give me an example where you have used a COM interface in your QTP project?

Com inteface 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 wil be one among those intefaces.

49.How can we insert Text check point and Bit map check point ? if provide example script, it is grateful ?

l To insert Text Check point we have two ways 1.While Recording 2.After Recording

1.While recording Insert->Checkpoint->Text Checkpoint is activated

For Example lets work on
mercury tours site:We want to check whether the date exists on the page using text check point.While recording click on the Text Check point and then go for the place where you need to check the text on the site.Our Example displays the following code after clicking OK on the dialog box that appears.

Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Check CheckPoint("Jul 13, 2006")

2.The same thing can be done after recording.Go to the Active screen and select the text and Right-Click to Insert Text Checkpoint where the same code appears

This is same thing with Insert Bitmap Checkpoint by above two ways

Insert->Checkpoint->Bitmap Checkpoint

Click on the image which you need to check

Browser("Welcome: Mercury Tours").Page("Find
a Flight: Mercury").Image("boxad1").Check CheckPoint("boxad1")

50.How to call a funtion present in dll file in QTP Script.

Execute_File "Path of the .vbs file "

52.How can we do block commenting in QTP?

Selecting the block and press (ctrl + M)

53.How to get the column count and column name from resultset in database connection program?

.example for recordcount

Set dbconn=createobject("adodb.connection")
dbconn.open "dsn=xxx"

Set objRecordset=createobject("ADODB.Recordset")
objRecordset.open "select * from logintable",dbconn,1,3

msgbox objRecordset.recordcount

2).for field names

For each x in objRecordset.fields
msgbox (x.name)

Next

 

54.What is difference between window(" ") and dialog(" ") in QTP while creating script?

Window is a seperate window that appears on clicking on a particular link on which we can perform actions like edit the content etc.This will contain many objects like chkbox,edit box, combo box etc.
Dialog box is used by developers

to validate a field.It will contain an alert message and OK or/and Cancel buttons.

55.How do you retrieve the Class name of a Test Object programmatically from within a script?

msgbox Browser

("QTP : How do you retrieve").Page("QTP : How do you retrieve").Frame("google

_ads_frame").Link("Fast Object Db/ODBMS").GetROProperty("micclass")

56.What is the Hotkey that can be used for Hitting spacebar?

There is no Hot key for space bar.
U can use (Type" ") command

57.How to write recovery scenario for below questions and what are the steps we will follow? if I click save button, it is not saving I want to write recovery scenario how?

To write Recovery scenario u must 1st stop recording when u get an error then from Tools menu-> select Recover Scenario Manager
When Recover Scenario Manager window is opened u can follow the steps as they r descriptive & select the appropriate option for the type of error u recieve, u have to select what action is to be performed if this particular error occurs after completing the entire procedure u need to save the scenario as well as the file.
Then thru Test-> Setting-> Recovery option attach the file to the recording & u do have a choice of whther to activate on every step or etc etc...
Thus you can use Recovery scenario to handle exceptions...

58.How do we test Links using Quick Test Professional and confirm that the page we are requesting is seen after clicking?

The links are tested using the property of 'href' and 'url' of that link. Here the link can be image or any. If the link is an image then the image has the properties as follows.Href or URL : check the hyperlinkAlt: Specifies the text of an imageSrc: Specifies image sourcefilename: specifies the name of the image file

59.After importing external .xls datasheet in to Datatable of QTP, How to set no. of iterations run for all row in the Datatable? I mean We dot know How many rows are existed before importing the .xls sheet

FOR i = 1 to datatable.getsheet("sheetname").getrowcount.getrowcount command will read up to the last record

60.How can I import and/or merge an existing repository into my current test?

Get Merge tool, you should get this once you install QTP + and you should getthis facility with other tools like Multitest Manager, Password encoder and batch runner.

61.How to retrive/update database by writing code in expert view In my case database is Access my dsn name="try" database name="employee.mdb"

Dim samp

Set samp=createobject("ADODB.Connection")

samp.ConnectionString="DSN=try"

samp.open strQuery="Select * from employee"

Set sampresults=samp.execute(strQuery)

a=sampresults.fields.count

Do until sampresults.eof

For i = 0 to a-1

b=sampresults.fields.item(i).value

reporter.ReportEvent 2,"column " & i , b

Next

sampresults.movenext

Loop

sampresults.close

samp.close

Set sampresults=nothing

Set samp=nothing

' for updating the table

strQuery="update employee set column name = new value where column name = some _value"

Set sampresults=samp.execute(strQuery)

62. What is the method used to focus on particular field.What is script in flights application login page by default, focus is on username field. for this we will check the focus was there or not by using getroproprty method but if focus is not there which method I need to use.

The method used to focus on particuler fie is

getroproperty: retrives the pericula property.

setroproperty: set the property to perticula object....

to focus to the perticulat text we can use this method:

object.GetTextLocation (TextToFind, Left, Top, Right, Bottom, [MatchWholeWordOnly])

object.GetTextLocation (TextToFind, Left, Top, Right, Bottom, [MatchWholeWordOnly]

63.How to test Dynamic web pages using QTP?

If you know the one property of the object .that is sufficient for the QTP to identify the object. if u know the one object property at that time we need to use object identifier to identify the object we need to add some more properties of the object. to give unique identification for the object. Or we need to go for the descriptive programming ,it bypass the object repository.

64.When a script is recorded in quick test for connecting 10 rows in the database, can we change script later for 20 rows either using vbscripting or from front-end can we make that particular change? If 'yes' how?

YES ,parametise the sql statement

65.What is meant by Source Control?

The practice of tracking changes made to code is called source Control
Familiar Source control Tools CVS, VSS, ClearCase etc

66.I have faced one question in interview he has given one screen with one bitmap and one edit box. The original bitmap is in data base. Question is first we get the bitmap from database and compare with the screen bitmap How we can get the bitmap from database.

With database checkpoint

67.How to change the Object Repository Mode using CODE?

ie from Shared to PerAction.

Set qApp = CreateObject("QuickTest.Application")
qApp.Test.Settings.Resources.ObjectRepositorytype = "Per Action"
Set qApp = Nothing

68.What are the check points can be inserted without recording?

Database and XML

69.How can I execute QTP scripts through command prompt?

Here it goes:"C:Program FilesMercury InteractiveQuickTest PlusUtilitiesCommandLineQuickTestLauncher.exe" /t "C:Automated ScriptsRegressionReg_Drilling" /r "D:results1" /logThe Syntax will be:"" /t "" /r "" /log

67.Which the Object Model the QTP uses for the Object identify of an application ? Choices are 1.DOM,2.DCOM,3.COM,4.ROM .

It is Component Object Model (COM).

68.How can we know the size of the object repository?

To know the size follow following steps

1) First export repository from tools-> object repository ->export

2)Then save it to some location and after that check the size of the file

69.How can we validate any date format like todays date(02/15/06)?

Code  for validation of date format. Date changes every day and it gives correct date.

Function todaydate'Return current monthCurr_Month = Month(Now)a=len(Curr_Month)If a=1 ThenCurr_Month = "0"&Curr_MonthEnd If'Return current dateCurr_Day = Day(Now)b=len(Curr_Day)If b=1 ThenCurr_Day = "0"&Curr_DayEnd If'Return current yearCurr_Year =Year(Now)c=Len(Curr_Year)If c=4 ThenCurr_Year = Right (Curr_Year, 2)End If todaydate = Curr_Month&"/" & Curr_Day &"/" & Curr_YearEnd Function 'Function callmsgbox

70.How can we test a stored procedure ?

Your function and save it asa .vbs file.U double click on it and make it error free.

Then in QTP , you go to Test->Settings->Resources.. and then click on the "+" symbol and browse the .vbs file and click on Apply Button.

After that Call your procedure with the "Call" Statement..It will
work

There is another way also

You can write this command like

executefile path,

specify the path of .vbs file , It will work

U can do either of the ways.

71.How to record and identify recursive hyperlinks

? Example if you have set of links in the first page(the only page you record), on clicking each link, you navigate to next page(s), which in turn has set of hyperlinks and so on till the last page.

This can be handled with a For loop ..

for ex:Searching a entity throughout multiple pages

for i = 0 to lastpage



Browser("ss").page("SSS").link("Reclinknext").click

next

72.How to make QTP to recognize the activeX controls.

QuickTest records and runs steps on ActiveX controls as it does on any other object.
Using the Insert>Step Option , we can activate ActiveX control methods, retrieve and set the values of properties and check the object exists.It is recommended that to begin recording session before opening the application

containing the ActiveX controls on    which you want to record.

73.How can you add a action (external action) programmatically?

You can add an external Action programmatically using the Command
RunAction ActionName, [IterationMode , IterationRange]
Before you can use the RunAction statement in the Expert View for an external action, you must first call or copy the external action into your test by choosing Insert > Copy of Action or Call to Action. If the external action does not exist in your test, the RunAction statement is not recognized.
Example
The following example calls the SearchFlight action, and runs all iterations of the action.
Call RunAction "SearchFlight", rngIterations, rngAll

74.How to add run-time parameter to a datasheet?

1.      Enter the data in data sheet(global/action).

2.      Right click on actionbutton it showing all possible codition.

3.      Choose run all Iteration row by row. in Qtp8.2
just choose options and run

 

75.How to select particular value from the combo box in the current page which is entered in the previous page edit box after parameterization?

To add the previous answer, in the Value field,
Datatable.Value()
This will select the item with the name of the parameterized value.

76.How the exception handling can be done using QTP?

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

77.What is the difference between check point and output value?

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]

 

78. How to Test Database Procedures and Triggers?

Before testing Data Base Procedures and Triggers, Tester should know that what is the Input and out put of the procedures/Triggers, Then execute  Procedures and   Triggers, if you get answer that  Test Case will be  pass  other wise fail.
These requirements should get from DEVELOPER

79.How to check a trigger is fired or not, while doing database testing?

It can be verified by querying the common audit log where we can able to see the triggers fired.

80.What steps does a tester take in testing Stored Procedures?

First the tester should to go through the requirement, as to why the particular stored procedure is written for.
Then check whether all the required indexes, joins, updates, deletions are correct comparing with the tables mentions in the Stored Procedure. And also he has to ensure whether the Stored Procedure follows the standard format like comments, updated by, etc.
Then check the procedure calling name, calling parameters, and expected reponses for different sets of input parameters.
Then run the procedure yourself with database client programs like TOAD, or mysql, or Query Analyzer
Rerun the procedure with different parameters, and check results against expected values.
Finally, automate the tests with WinRunner

81.What are the different stages involved in Database Testing

verify field level data in the database with respect to front-end transactions
verify the constraint (primary key, foreign  key ....)
verify the performance of the procedures
verify the triggers (execution of triggers)
verify the transactions (begin,commit,rollback)

82.In the QTP the snap shots obtained during  the recording time will appear in the active screen, if we have to use the snapshots from where we have to access. in which memory location of QTP they will be stored?
C:\Program Files\Mercury Interactive\QuickTest 
Professional\Tests\tutorial\Test1\Action1\SnapShots
 
83.If there are 10 windows open in QTP write a command to close 
all 10 windows at a time ?
SystemUtil.CloseProcessByWndTitle "*.*", True
 
84.How to explain the architecture of one particular project.
Architecture of particular project means one tier or two tier or three tier project. For example if a project application is two tire it is communicate between client  and server directly. If the application communicate between client system and web server after that web server server of the application is called three tire structures. Project architecture means not only 2-tier/n-tier, we need to explain how the systems are connected within the systems, how the communication happens between different systems including third party components etc.
 
85.Can you  Reduce the size of Object repository? What are the problems u have faced in Qtp tool?
Using Descriptive Programming we can reduce the size of Object Repository. No need to Maintain object Repository if you use descriptive Programming Concepts. QTP recognize each object with some unique Property values. So you no need to add object to object repository if you use descriptive programming. Descriptive programming reduces the time of QTP to recognize the object uniquely. If you use Object Repository, first QTP retrieves all objects from it and verify each property values of the object and it is time 
taken process. If the number of objects in Object Repository is huge, QTP takes so much time to recognize the object you specified in the Script.
 
The following Properties can be used to recognize the 
objects uniquely by QTP.
Object Name         Properties to recognize the object
Browser             Name
Page                Title
WebEdit             Name
WebEelemt           InnerText/Html id
WebList             Name
WebButton           Name
Link                Name
WebTable            Html id/Name
 
86.What is output value in QTP? Why do we use the output value 
in QTP?How many types of output values are there in QTP?
what are their respective usage in QTP?
Using o/p values u can retrieve properties of objects ,database field values ,text presenting objects & can store on data table in test result window.
QTP provide diffrent o/p values i.e
-standard o/p values
-text o/p
-database o/p
-XML o/p
-text area 
 
Standard o/p values can retrieve number of properties an object 
Note:o/p values retrieve run time datatable in test result  window text o/p:using to retrive d text present in objects & store in run time datatable text area:retrive test present in bitmap & retrive specific string frm obj.
 
 

 

 

 

 

 

No comments:

Post a Comment