Total Pageviews

Wednesday, October 13, 2010

QuickTestPro Interview Questions and Answers part 4



1.     How can we check the location of a cell to be checked in a Column of a table?

The settings in the Cell Identification tab determine how QTP locates the cells to be checked. The settings in this tab apply to all selected cells.
The Cell Identification tab includes the following options:

i. Identify columns : Specifies the location of the column (in your actual table) containing the cell(s) to which you want to compare the expected data.

· By position. (Default) Locates cells according to the column position. A shift in the position of the columns within the table results in a mismatch.

· By column name. Locates cells according to the column name. A shift in the position of the columns within the table does not result in a mismatch. (Enabled only when the table contains more than one column.)

ii. Identify rows : Specifies the location of the row (in your actual table) containing the cell(s) to which you want to compare the expected data.

· By row number. (Default) Locates cells according to the row position. A shift in the position of any of the rows within the table results in a mismatch.

· By selected key column(s). Locates the row(s) containing the cells to be checked by matching the value of the cell whose column was previously selected as a key column. A shift in the position of the row(s) does not result in a mismatch. If more than one row is identified, QTP checks the first matching row. You can use more than one key column to uniquely identify any row.

Note: A key symbol is displayed in the header of selected key columns.

iii. Use value match criteria to identify data in the key column: Instructs QTP to use the verification type settings from the Settings tab as the criteria for identifying data in the key column.

Enabled only when you select to identify rows By selected key column(s).

http://futurethoughtsllc.com/QTPInterviewQuestionsAnswers.aspx

2.     How do I make the QTP test prompt the user for input while it is running ?

The VBScript InputBox function enables you to display a dialog box that prompts the user for input and then continues running the test. You can use the value that was entered by the user later in the run session. For more information on the InputBox function, refer to the VBScript Reference.

The following example shows the InputBox function used to prompt the user for a password.

Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").Set "administrator"
Passwd = InputBox ("Enter password", "User Input")
Browser("Mercury Tours").Page("Mercury Tours").WebEdit("password").Set Passwd


3.     How can we check the location of a cell to be checked in a Row of a table?

The settings in the Cell Identification tab determine how QTP locates the cells to be checked. The settings in this tab apply to all selected cells.

Identify rows : Specifies the location of the row (in your actual table) containing the cell(s) to which you want to compare the expected data.

· By row number. (Default) Locates cells according to the row position. A shift in the position of any of the rows within the table results in a mismatch.

· By selected key column(s). Locates the row(s) containing the cells to be checked by matching the value of the cell whose column was previously selected as a key column. A shift in the position of the row(s) does not result in a mismatch. If more than one row is identified, QTP checks the first matching row. You can use more than one key column to uniquely identify any row.


4.     How can we check the object property values in our application?

You can check the object property values in your Web site or application using standard checkpoints. Standard checkpoints compare the expected values of object properties captured during recording to the object's current values during a run session.

You use standard checkpoints to perform checks on images, tables, Web page properties, and other objects within your application or Web site.

Note: You can create standard checkpoints for all supported testing environments (as long as the appropriate add-ins are loaded).


5.     How can we compare objects among two object repositories in QTP?

Using the Object Repository Comparison Tool, you can compare two object repositories according to predefined settings that define how differences between objects are identified.

To compare two object repositories:

1. In QTP Professional, choose Resources > Object Repository Manager.

2. In the Object Repository Manager, choose Tools > Object Repository Comparison Tool. The New Comparison dialog box opens on top of the Object Repository - Comparison Tool window.
(click on the below image to see clear view)
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi-gdqecu5OyQJ0zuBfy3ETlz3W8Ms9bFvTsBF-w3-pZ6YbQcxkLg8Kd-zdcidX2Z1LcW_uKleJ7ctHw7kac-na5dv4IRIoPEgRShDUXo-MvHpLFKq05Ju1qoX1aUjOxsSAbGwY3O9gfY/s200/image006.jpg

6.     How can we compare the image files in the Image Checkpoint in QTP?

Image checkpoints enable you to check the properties of a Web image. In the Image Checkpoint Properties dialog box, you can specify which properties of the image to check and edit the values of those properties. This dialog box is similar to the standard Checkpoint Properties dialog box, except that it contains the Compare image content option. This option enables you to compare the expected image source file with the actual image source file.


7.     How can we create a QTP Test in Quality Center?

To create a business process test, the Subject Matter Expert selects (drags and drops) the components that apply to the business process test and configures their run settings.

Note: When you run a business process test from Quality Center, the test run may also be influenced by settings in the QTP Remote Agent.

Each component can be used differently by different business process tests. For example, in each test the component can be configured to use different input parameter values or run a different number of iterations.

If, while creating a business process test, the Subject Matter Expert realizes that a component has not been defined for an element that is necessary for the business process test, the Subject Matter Expert can submit a component request from the Test Plan module.
http://futurethoughtsllc.com/QTPInterviewQuestionsAnswers.aspx


8.     How can I record and run tests on objects that change dynamically from viewing to viewing?

Sometimes the content of objects in a Web page or application changes due to dynamic content. You can create dynamic descriptions of these objects so that QTP will recognize them when it runs the test.


9.     How can we debug a Function Library?

Before you can debug a function library, you must first associate it with a component (via its application area) and then insert a call to at least one of its functions. For example, you can use the Debug Viewer to view, set, or modify the current value of objects or variables in your function library. You can step into functions (including user-defined functions), set breakpoints, stop at breakpoints, view expressions, and so forth. You can begin debugging from a specific step, or you can instruct QTP to pause at a specific step.

Note: During a debug session, all documents are read-only and cannot be edited. To edit a document during a debug session, you must first stop the debug session.

After you create a component or function library (including registered user functions), you should check that they run smoothly, without errors in syntax or logic. To debug a function library, you must first associate it with a component via its application area and then debug it from that component.

To detect and isolate defects in a component or function library, you can control the run session using the Pause command as well as various step commands that enable you to step into, over, and out of a specific step.

You can use the Debug from Step command to begin your debug session at a specific point in your component. You can also use the Run to Step command to pause the run at a specific point in your component. You can set breakpoints, and then enable and disable them as you debug different parts of your component or function library.

When the component or function library run stops at a breakpoint, you can use the Debug Viewer to check and modify the values of VBScript objects and variables. Also, if QTP displays a run error message during a run session, you can click the Debug button on the error message to suspend the run and debug the component or function library.

You can also use the Run from Step command to run your component or function library from a selected step to the end. This enables you to check a specific section of your application or to confirm that a certain part of your component or function library runs smoothly.

Notes:

- While the component and function libraries are running in debug mode, they are read-only. You can modify the content after you stop the debug session (not when you pause it). If needed, you can enable the function library for editing (File > Enable Editing) after you stop the session.

After you implement your changes, you can continue debugging your component and function libraries.

- If you perform a file operation (for example, open a different component or create a new component), the debug session is stopped.

- In QTP, when you open a component, QTP creates a local copy of the external resources that are saved to your Quality Center project. Therefore, any changes you apply to any external resource that is saved in your Quality Center project, such as a function library, will not be implemented in the component until the component is closed and reopened. (An external resource is any resource that was not created using QTP, such as, a function library created in an external editor.)

10.   How can we define a time interval for QTP to perform a checkpoint successfully?

You can specify the time interval during which QTP attempts to perform the checkpoint successfully by modifying the selections in the bottom part of the Text/Text Area Checkpoint Properties dialog box. You can also specify when to perform the checkpoint.
• Checkpoint timeout. Specifies the time interval (in seconds) during which QTP attempts to perform the checkpoint successfully. QTP continues to perform the checkpoint until it passes or until the timeout occurs. If the checkpoint does not pass before the timeout occurs, the checkpoint fails.
For example, suppose it takes some time for an object to achieve an expected state. Increasing the checkpoint timeout value in this case can help ensure that the object has sufficient time to achieve that state, enabling the checkpoint to pass (if the data matches) before the maximum timeout is reached.
If you specify a checkpoint timeout other than 0, and the checkpoint fails, the Test Results window displays information on the checkpoint timeout.
• Insert statement. Specifies when to perform the checkpoint. Choose Before current step if you want to check the value of the text before the highlighted step is performed. Choose After current step if you want to check the value of the text after the highlighted step is performed.
Note: The Insert statement option is not available when adding a new text checkpoint or a text area checkpoint during recording, or when modifying an existing checkpoint. It is available only when adding a new text checkpoint to an existing test while editing.
http://futurethoughtsllc.com/QTPInterviewQuestionsAnswers.aspx


11.   How can we Disable Smart Identification During the Run Session in QTP?

Selecting the Enable Smart Identification check box for a particular test object class instructs QTP to learn the property values of all properties specified as the object's base and/or optional filter properties in the Smart Identification Properties dialog box.

By default, some test objects already have Smart Identification configurations and others do not. Those with default configurations also have the Enable Smart Identification check box selected by default.

http://futurethoughtsllc.com/QTPInterviewQuestionsAnswers.aspx

12.   You should enable the Smart Identification mechanism only for test object classes that have defined Smart Identification configuration. However, even if you define a Smart Identification configuration for a test object class, you may not always want to learn the Smart Identification property values. If you do not want to learn the Smart Identification properties, (To Disable Smart Identification in QTP) clear the Enable Smart Identification check box.

Note: Even if you choose to learn Smart Identification properties for an object, you can disable use of the Smart Identification mechanism for a specific object in the Object Properties or Object Repository dialog box.
However, if you do not learn Smart Identification properties, you cannot enable the Smart Identification mechanism for an object later.


13.   How can we do part running of the QTP Test script?
The Run from Step option in the Test menu is used to run the test from a selected step to the end of the current action, if running from the Expert View, or to the end of the test , if running from the Keyword View. Thus it enables us to check a specific part of the application or to confirm that a certain part of the test runs correctly.
http://futurethoughtsllc.com/QTPInterviewQuestionsAnswers.aspx


14.   How can I check by QTP that a child window exists (or does not exist)?
Sometimes a link in one window creates another window.
You can use the Exist property to check whether or not a window exists. For example:
Browser("Window_name").Exist
You can also use the ChildObjects method to retrieve all child objects (or the subset of child objects that match a certain description) on the Desktop or within any other parent object.

How can we do the nesting of If...Then...Else statement in QTP?
If condition Then
[statements]
[ElseIf condition-n Then
[elseifstatements] . . .
[Else
[elsestatements]
End If


15.   How can we ensure that a text string appears in a specified area in QTP?
In the Text/Text Area Checkpoint Properties dialog box, you can specify the text to be checked as well as which text is displayed before and after the checked text. These configuration options are particularly helpful when the text string you want to check appears several times or when it could change in a predictable way during run sessions.

For example, suppose you want to check the third occurrence of a particular text string in a page. To check for this string, you can specify which text precedes and/or follows it and to which occurrence of the specified text string you are referring.


16.   How can we identify a checkpoint in QTP?
QTP enables you to add checks to your test. A checkpoint is a verification point that compares a current value for a specified property with the expected value for that property. This enables you to identify whether your Web site or application is functioning correctly.

When you add a checkpoint, QTP adds a checkpoint to the current row in the Keyword View and adds a Check CheckPoint statement in the Expert View. By default, the checkpoint name receives the name of the test object on which the checkpoint is being performed. You can choose to specify a different name for the checkpoint or accept the default name.

When you run the test, QTP compares the expected results of the checkpoint to the current results. If the results do not match, the checkpoint fails. You can view the results of the checkpoint in the Test Results window.

Tip: You can also use the CheckProperty method and the CheckItemProperty method to check specific property or item property values.

Note: If you want to retrieve the return value of a checkpoint (a boolean value that indicates whether the checkpoint passed or failed), you must add parentheses around the checkpoint argument in the statement in the Expert View. For example:

a = Browser("MyBrowser").Page("MyPage").Check (CheckPoint("MyProperty"))
http://futurethoughtsllc.com/QTPInterviewQuestionsAnswers.aspx


17.   How can we incorporate decision-making into the QTP tests?
Using conditional statements, you can incorporate decision making into your tests. Using loop statements, you can run a group of steps repeatedly, either while or until a condition is true. You can also use loop statements to repeat a group of steps a specific number of times.
After you insert a conditional or loop statement in the Keyword View, you can insert or record steps after the statement to include them in the conditional or loop block.


18.   How can we increase the Readability of our QTP Tests scripts?
To increase readability, use With Statement.
You can instruct QTP to automatically generate With statements for the steps you record. When you select this option, statements are displayed in their normal format while recording. When you stop recording, the statements in all actions recorded during the current recording session are automatically converted to the With format.


19.   To generate With statements automatically when you record:
1. Choose Tools > Options or click the Options toolbar button. The Options dialog box opens.
2. In the General tab, select Automatically generate "With" statements after recording.
3. Enter the minimum number of consecutive, identical objects for which you want to apply the With statement in the Generate "With" statements for __ or more objects box.
The default is 2.

Note: This setting is used when you use the Apply "With" to Script option as well as for the Automatically generate "With" statements after recording option.

For example, if you only want to generate a With statement when you have three or more consecutive statements based on the same object, enter 3.

4. Begin recording your test. While recording, statements are recorded normally. When you stop recording, the statements in all actions recorded during the current recording session are automatically converted to the With format.
The With statement has the following syntax.
With object
.....statement
.....statement
.....statement
End With

For example, you could replace this script:
Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "19097 LON "
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click

with the following:

With Window("Flight Reservation")
.WinComboBox("Fly From:").Select "London"
.WinComboBox("Fly To:").Select "Los Angeles"
.WinButton("FLIGHT").Click
With .Dialog("Flights Table")
.WinList("From").Select "19097 LON "
.WinButton("OK").Click
End With 'Dialog("Flights Table")
End With 'Window("Flight Reservation")

Note: Using With statements in your test has no effect on the run session itself, only on the way your test appears in the Expert View. Generating With statements for your test does not affect the Keyword View in any way.

http://futurethoughtsllc.com/QTPInterviewQuestionsAnswers.aspx

20.   How does QTP record on dynamically generated URLs and Web pages?
QTP actually clicks links as they are displayed on the page. Therefore, QTP records how to find a particular object, such as a link on the page, rather than the object itself. For example, if the link to a dynamically generated URL is an image, then QTP records the "IMG" HTML tag, and the name of the image. This enables QTP to find this image in the future and click on it.



21.   How can we insert a checkpoint or output value statement in Expert View of QTP Manually?
We cannot insert standard checkpoints and other predefined checkpoints or output value statement in Expert View of QTP Manually.
But we can insert descriptive checkpoints (Like If… Else) in the expert view of QTP while editing/updating the test scripts.


22.   How can we Integrate QTP with Quality Center?
At its most basic level, integrating QTP with Quality Center enables you to store and access QTP tests and function libraries in a Quality Center project, when QTP is connected to Quality Center.

In addition, your tests and function libraries can use the QCUtil object to access and use the full functionality of the Quality Center OTA (Open Test Architecture)—formerly known as TestDirector OTA or TDOTA. This enables you to automate integration operations during a run session, such as reporting a defect directly to a Quality Center database.
You can also use the TDOTA object in your QTP automation scripts to access the Quality Center OTA.


23.   How can we locate Test Objects in an Object Repository in QTP?
You can select an object in the application or Web site you are testing and highlight the test object in the object repository.

For example, to locate a Find a Flight image in a Web page, you can select it in your Web page using the pointing hand mechanism. After you select the Find a Flight image object from the selection dialog box and click OK, the parent hierarchy in the object repository tree expands and the Find a Flight image test object is highlighted.

To locate an object in the object repository:
1. Make sure your application or Web site is open to the correct window or page.
2. Click the Locate in Repository button or choose View > Locate in Repository. QTP is hidden, and the pointer changes into a pointing hand.
3. Use the pointing hand to click on the required object in your application or Web site.

Tip: You can hold the left CTRL key to change the window focus or perform operations such as right-clicking or moving the pointer over an object to display a context menu. If the window containing the object you want to click is partially hidden by another window, you can also hold the pointing hand over the partially hidden window for a few seconds until the window comes into the foreground and you can point and click on the object you want. Additionally, if the window containing the object you want to select is minimized, you can display it by holding the left CTRL key, right-clicking the application in the Windows task bar, and choosing Restore from the context menu.
If the location you clicked is associated with more than one object, the Select an Object dialog box opens.
4. Select the object you want to locate in the object repository and click OK. The selected object is highlighted in the object repository.
5.Tip: If the relevant object repository is not open or the object cannot be found, the object is not highlighted. In the Object Repository Manager, if more than one shared object repository is open, and QTP cannot locate the selected object in the active object repository, you can choose whether to look for the object in all of the currently open object repositories.


24.   How does QTP handle cookies?
Server side connections, such as CGI scripts, can use cookies both to store and retrieve information on the client side of the connection.
QTP stores cookies in the memory for each user, and the browser handles them as it normally would.


How can we parameterize a step in QTP?
Parameterize the method argument of the fromPort step:

In the Keyword View, click in the Value cell of the step and then click the parameterization icon. In the Value Configuration Options dialog box, select the Parameter radio button. In the Name box, rename p_item to Location.

Click OK. The Location column is added to the Data Table.
http://futurethoughtsllc.com/QTPInterviewQuestionsAnswers.aspx


25.   How can we perform Import & Export Operations among various Object Repositories in QTP?
You can export all of the objects contained in an action's local object repository to a new shared object repository in the file system or to a Quality Center project (if QTP is connected to Quality Center). This enables you to make the local objects accessible to other actions. You export local objects to a new shared object repository using the Object Repository window.


26.   To export local objects to a new shared object repository:
1. Open the test that has the local objects you want to export.
2. Make sure that the Object Repository window is open.
3. In the Object Repository window, in the Action box, choose the action whose local objects you want to export.
4. Choose File > Export Local Objects. The Export Object Repository dialog box opens.

Note: If you are connected to Quality Center, the dialog box that opens is different from the standard file system dialog box. You can switch between the two dialog box versions by clicking the File System and Quality Center buttons in the Export Object Repository dialog box.
5. Select the location in which to save the file, specify the file or attachment name, and click Save or OK (depending on whether you are saving it to the file system or a Quality Center project).
The object repository is exported to the specified shared object repository (a file with a .tsr extension). You can now use the new shared object repository like any other shared object repository.

Tip: After you export the local objects, you can use the Object Repository Merge Tool to merge the shared object repository containing the exported objects with another shared object repository.

How can we perform Merge Operations among various Object Repositories in QTP?
QTP Professional provides the ability to merge existing assets from two object repositories into a single shared object repository using the Object Repository Merge Tool. This tool enables you to merge two shared object repositories (called the primary object repository and the secondary object repository), into a new third object repository, called the target object repository. Objects in the primary and secondary object repositories are automatically compared and then added to the target object repository according to preconfigurable rules that define how conflicts between objects are resolved.

After the merge process, the Object Repository Merge Tool provides a graphic presentation of the original objects in the primary and secondary object repositories, which remain unchanged, as well as the objects in the merged target object repository. Objects that had conflicts are highlighted. The conflict of each object that you select in the target object repository is described in detail. The Object Repository Merge Tool provides specific options that enable you to keep the suggested resolution for each conflict, or modify each conflict resolution individually, according to your requirements.

The Object Repository Merge Tool also enables you to merge objects from the local object repository of one or more actions into a shared object repository. For example, if QTP learned objects locally in a specific action in your test, you may want to add the objects to the shared object repository, so that they are available to all actions in different tests that use that object repository.
You open the Object Repository Merge Tool by choosing Tools > Object Repository Merge Tool in the Object Repository Manager.
http://futurethoughtsllc.com/QTPInterviewQuestionsAnswers.aspx


27.   How can we retrieve all objects located inside a Parent Object with QTP?
You can use the ChildObjects method to retrieve all objects located inside a specified parent object, or only those child objects that fit a certain programmatic description. To retrieve this subset of child objects, you first create a description object and add the set of properties and values that you want your child object collection to match using the Description object.
Note: You must use the Description object to create the programmatic description for the ChildObjects description argument. You cannot enter the programmatic description directly into the argument using the property:=value syntax.

Once you have "built" a description in your description object, use the following syntax to retrieve child objects that match the description:

Set MySubSet=TestObject.ChildObjects(MyDescription)
For example, the statements below instruct QTP to select all of the check boxes on the Itinerary Web page:
Set MyDescription = Description.Create()
MyDescription("html tag").Value = "INPUT"
MyDescription("type").Value = "checkbox"
Set Checkboxes = Browser("Itinerary").Page("Itinerary").ChildObjects(MyDescription)
NoOfChildObjs = Checkboxes.Count
For Counter=0 to NoOfChildObjs-1
Checkboxes(Counter).Set "ON"
Next

In the Test Results, square brackets around a test object name indicate that the test object was created dynamically during the run session using the ChildObjects method or a programmatic description.


28.   Where can I find a Web page's cookie with QTP?
The cookie used by the browser can be accessed through the browser's Document Object Model (DOM). In the following example the cookie collection is returned the from the browser.
Browser("Flight reservations").Page("Flight reservations").Object.Cookie

29.   How QTP recognizes objects in Object Repositories?

In QTP, the Object Repository window displays a tree of all objects in the current component or in the selected action (including all local objects and all objects in any shared object repositories associated with the selected action or component).

we can view or modify the test object description of any test object in the repository or to add new objects to the repository.
QTP 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.




Does QTP work with .asp?

Dynamically created Web pages utilizing Active Server Page technology have an .asp extension. This technology is completely server-side and has no bearing on QTP.


No comments:

Post a Comment