Wednesday, January 12, 2011

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

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

What is Test Frame Work?
Automation framework is one....it is a test plan for
automation testing which drives entire automation testing
in a sytemamatic and scientific manner to execute the test
script like Main Script--->DriverScripts--->Environment
variables, Library files, Functions, Test Data(data table -
Parameterization.

Here MainTest Script will call the DriverScripts
DriverScripts will call the required Env, Lib files,
Func.....etc.

So the entire test will be executed/carried out in a flow
like explained above.(This comes under Keyword Driven
Framework).

What is Description Object?
The description object enables descriptive programming which is basically accessing GUI objects without actually recording / storing them in an Object Repository. The description object will store a set of "properties" typically a "name and value pair" for a particular "class" which then can be accessed with the help of the description object.
e.g:
Set obj_desc = Description.Create
obj_desc("html_tag").value = "Password"
obj_desc("name").value = "txtUserPassword"
The name/value pair in this case is "html_tag" and "Password".It implies that the gui object will be an html tag with the tag name as Password.
Hence in the above case we manage to identify the gui object without actually referring to the object repository and then can use it inside the code to manipulate / perfrom operations on that object.
What is the difference between Normal mode and Fast mode?
normal mode: runs your test or component with the execution arrow to the left of the keyword view or expert view, marking each step or statement as it is performed. If the test contains multiple actions, the tree in the keyword view item column expands to display the steps, and the expert view displays the script, of the currently running action. You must have microsoft script debugger installed to enable this mode. fast mode. Runs your test or component without the execution arrow to the left of the keyword view or expert view (for tests) and does not expand the item tree or display the script of each action as it runs. This option requires fewer system resources
What is the Obect Repository type
Object Repository: 2 types ( Per-action, Shared)
Per-Action: Default , but it is not reusable , used to that
current test only, Extension :- Mtr
Shared:its a reusable repository, we can use in multiple
scripts ,extension :- tsr
using this syntax : repositoriescollection.add("Path") we
can use int script itself

How do you close the Task Manager through QTP?

First you should add the Task Manager dialog box in the object repository.
This is not a modal dialog box so you can add it to repository easily.
Then use following simple code.

If Dialog("Windows Task Manager").Exist Then
Dialog("Windows Task Manager").Close
Reporter.ReportEvent micPass "Task Manager" "Successfully closed task
manager"
Else
Reporter.ReportEvent micFail "Task Manager" "Task Manager is not open"
End If
How will you load the object during run time?
1. Well, we won’t load objects during runtime, we only instruct QTP to interact with an object so it identifies it during runtime. QTP stores object definitions, or Test Object properties and along with those, it also stores Runtime object properties in its Object Repository. When the test runs, QTP maps these test object properties with the object’s runtime properties. If it successfully maps the runtime properties, test passes. If not, test fails.

If you were asking about creating an instance of a particular application (or process) via QTP, then yes, it can be done using the “CreateObject” function. CreateObject basically creates an instances of an OLE Automation.

For example, I want QTP to initiate an instance of Microsoft Excel, you would do it something like this:

Dim oExcel
Set oExcel=CreateObject(Excel.Application)
oExcel.Launch ‘(Just for reference) Start Excel
oExcel.visible=True ‘(Just for reference) Make Excel Application visible

InStr Function
Returns the position of the first occurrence of one string within another.
InStr([start, ]string1, string2[, compare])
start
Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. If start contains Null, an error occurs. The start argument is required if compare is specified.
string1
Required. String expression being searched.
string2
Required. String expression searched for.
compare
Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. If omitted, a binary comparison is performed.
Dim SearchString, SearchChar, MyPos
SearchString ="XXpXXpXXPXXP" ' String to search in.
SearchChar = "P" ' Search for "P".
MyPos = Instr(4, SearchString, SearchChar, 1) ' A textual comparison starting at position 4. Returns 6.
MyPos = Instr(1, SearchString, SearchChar, 0) ' A binary comparison starting at position 1. Returns 9.
MyPos = Instr(SearchString, SearchChar) ' Comparison is binary by default (last argument is omitted). Returns 9.
MyPos = Instr(1, SearchString, "W") ' A binary comparison starting at position 1. Returns 0 ("W" is not found).

What is test object?

Test Object is used by QTP to identify an object in the AUT during playback. While Run Time object that actually exists in the application
How QTP recognizes the objects stored in object repository
1. QTP uses the Object Repository to identify objects in the AUT. How will it identify objects stored in the OR? Well, the same way we identify each other because we have their "description" stored in our brain. Even though this is a bad example, but for the sake of explanation, let's say OR is the brain of QTP.

When QTP encounters an objects, it searches for that object in its brain and if it has encountered that object before, it performs the necessary action. If it does not, it fails the test; the same way, if you haven’t seen a person ever before and they ask for you to lend them $100, you would go like “Do I know you?” and walk away.

The OR should contain all the objects that you need for your tests to run successfully. If you want to write a keyword-driven script in QTP to login a user in www.gmail.com, you will have to access the Browser, the respective page, the username field, the password field and the SignIn button. All these objects will be then stored in QTP’s OR. So after you are done recording, you will playback the script and have the user login. This is done because QTP has already stored object definitions for all the objects it has to interact with in its OR.

There are ways to bypass this, by using Descriptive Programming and not making use of QTP’s OR. So, it entirely depends on what you want to use and what you are the most comfortable with.

No comments:

Post a Comment