0% found this document useful (0 votes)
111 views19 pages

QTP Misc

The document discusses new features introduced in QTP 11 and QTP 11.5. QTP 11 introduced a new results viewer, visual relation identifier, log tracking functionality, add-ins for various web toolkits, XPath and CSS based object identification, and more. QTP 11.5 merged QTP and Service Test into a single tool, introduced an updated IDE, insight for image-based identification, file content checkpoints, and more.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views19 pages

QTP Misc

The document discusses new features introduced in QTP 11 and QTP 11.5. QTP 11 introduced a new results viewer, visual relation identifier, log tracking functionality, add-ins for various web toolkits, XPath and CSS based object identification, and more. QTP 11.5 merged QTP and Service Test into a single tool, introduced an updated IDE, insight for image-based identification, file content checkpoints, and more.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Firstly let us check what all the new features/Enhancements was introduced in QTP-11:-

New Results Viewer

Visual Relation Identifier

Log Tracking functionality helps you work with developers to pinpoint the root
causes of unexpected behavior in your application

QuickTest 11.00 provides Web Add-in Extensibility-based add-ins for ASP .NET
Ajax, GWT, Yahoo UI, and Dojo Web 2.0 toolkits

XPath and CSS based object identification(Used in Selenium)

Load Function Libraries at Run Time

Automatically Parameterize Steps

New Silverlight Add-in to test objects in Silverlight 2 and Silverlight 3


applications.

Extended WPF and Silverlight Support

New Object Spy Functionality

Compare, Merge, and Export Object Repositories with Checkpoints and Output
Values

Add Images to Your Run Result

FireFox-3.5( Record Support) ,Internet Explorer 8

Lets check the UFT-11.5(QTP-11.5) Feature list:-

One Unified Tool for GUI + API testing (Merger of QTP + Service Test)

Modern IDE:- Solution Explorer,Canvas-Style Test Flow

MDI: Edit Multiple Testing Documents Simultaneously

Insight: Image-Based Object Identification

File Content Checkpoints(New checkpoints for PDF, HTML, Word, TXT, and RTF
files)

Support for MSAA-Based (Microsoft Office and Plug-in) Controls

Export GUI Tests from Sprinter Exploratory Tests(From XML)

New GUI Testing Support for Qt and Adobe Flex Applications

Test your work against an SAP server by importing IDocs and RFCdefinitions from
your SAP systems(API)

Debug Steps Using the Run Step Command (API)

Use Your soapUI Tests in UFT (API)

Automatically Export Run Results

Record Toolbar

Supports storing and managing your GUI tests in SAP Solution Manager

1. How many number of Columns can we have in a


Datatable?
2. How we can save Local Object Repository?
3. Various full forms of extensions (.qfl, .qrs, .tsr, .mtr)?
4. Can we have IF condition without End if?
5. Various methods of commenting a statement in UFT?
6. Please tell the various tools available in Object Repository
manager?

7. Can you please tell the various ways to access the Excel
datasheet?

8. Sequence of steps followed by UFT to identify object in an


application?
9. How to use SetRoProperty in UFT?
10. How can we access number of items in a weblist?
Note: - For answers Please refer the post
1. 256 columns

2. We cant save local OR it is saved by default .


3. Please refer the below :-

I. .QFL (Quick Test Function Library)


II. .QRS(Quick Test Recovery Scenario)
III. .TSR(Test Script Repository) , Friends I use
to refer this as Test Shared Repository, but after clarification
from HP Training team I got the right full form, in most of
the internet materials it is referred as Shared Repository
but sorry to say that is wrongly given).
IV. .MTR(Module Test Repository) on most of
the websites it is again given as Mercury Test Repository, as
per HP this is wrong)

4. Yes, dont get me wrong just try out the following line
of code in UFT, you can verify it:Dim var : var = 0
Writing the IF condition without End if
IF var=0 THEN MSGBOX Zero ELSE Non Zero

Thing is that we can avoid ENDIF, in case we are writing the


IF condition in single line.

5. We can use either Keyword REM before the comment


statement or symbol apostrophe i.e.

6. Below are the tools available in OR Manager:I. Merge tool


II. Comparison Tool
III. Update from Local repository
7.We can access Excel database in following ways:I. Creating an object of Excel using CreateObject:Set objExcel = CreateObject(Excel.application) Creating
excel object
objExcel.open C:/Test.xls Setting the path of the file to
open
objExcel.Visible = True Making the opened Excel file visible

II. Using the ADO database object


Dim str
str = C:/Test.xls Excel Path
Set objADO = CreateObject(ADODB.Connection)
Set objRS = CreateObect(ADODB.RecordSet)
ObjADO.ConnectionString = Driver = {Microsoft Excel
Driver(*.xls)};DBQ=&str
ObjRS = ObjADO.Exceute(Select * from Sheet1)
Do until EOF
Fetching the data from excel until data exists

Loop
Obj.RS.Close
ObjADO.close

Note: - Code is not explained Ill explain in my exclusive


post on database.

8. Mandatory Properties -> Assistive Properties -> Visual


Relation Identifier->Ordinal Identifier->Smart Identification.

9. This property doesnt exist, if we think logically how can


we set Runtime property of a Real object in application

10. By using GetRoProperty in a weblist.


Browser ().Page ().Weblist ().GetRoProperty (items
count)

What is the difference between Dictionary and


Array?
Solution:1.For using Dictionary, we need to create its object using "CreateObject", method, while
Array is declared like normal variables using "Dim"
Example:Creating Dictionary Object
Set obj = createobject("scripting.dictionary")
'Declaring array
Dim arr(0)

2.Dictionary is more flexible and is richer in terms of built-in functionality. (It has range of
methods and properties like Items, remove, Keys,Exists)
Example:'Creating Dictionary Object
Set obj = createobject("scripting.dictionary")
'Using Add methods to add values to dictionary object
obj.Add "UFT","2012"
obj.Add "QTP11","2010"
obj.Add "QTP10","2009"

3.Dictionaries also work better when you want to locate items by their content rather than

their position, so we use item property


Example:'Locating items in Dictonary
MsgBox obj.item("UFT")

4.Array uses ReDim to vary the size while we don't need this in dictionary's .
'Declaring array
Dim arr()
'Resizing Array
ReDim arr(1)
arr(0) = "UFT"
arr(1) = "QTP11"
msgbox arr(0)

5.When you delete a particular item from a dictionary, all the subsequent items
automatically shifts up
6.Most important of all is that Array can have index only as numeric (0,1,2..) while we can
use keys to identify dictionary items and Keys can be of any data subtype(String,integer),
except an array or dictionary.
7.Dictionary can't be multidimensional like Array's
PART-2

Today i thought of sharing the common practical


scenario to excel in Interview of UFT/QTP
Scenario:-

We want UFT to select checkbox in the table corrensponding to company name of "Oracle".

Dear readers please share your solutions, it will be


of great help for buddy job seekers
2 COMMENTS:
Mahendra Selukar said:
24 June 2013 22:51
First apply table checkpoint on specified table and edit that checkpoint as below
nIndex=Browser("").Page("").Frame("MainFrame").WebTable("").GetRowWithCellText("Oracle")
Now Use DP
Set oChekBox = Description.Create
oChekBox ("micClass").Value = "WebCheckBox"
oChekBox ("Index").Value = nIndex
Browser("").Page("").Frame("").WebCheckBox(oChekBox).Set "ON"
Hope it will work for this scenario...

Chaitanya C said:
29 October 2013 10:16
nIndex=Browser("").Page("").Frame("MainFrame").WebTable("").GetRowWithCellText("Oracle")
Now Use DP
Set chkobj =
Browser("").Page("").Frame("").WebTable("").ChildItem(3,2,"WebCheckbox",0)
chkobj .Set "ON"

PART-3

Interview Questions (Part-3)


1. What are disadvantages of Shared Object Repository?
2. Please explain what all can be saved in Resources tab of
ALM/QC?
3. How we can load OR at Run time?
4. Explain the process to work with Batch files in QTP?
5. What are the types of Descriptive programming (DP)? Where
we can use them?
Answers:1. Following are the main disadvantages of Shared OR:

As this is shared across projects, incase user


deletes\updates any of the object by mistake, it results in
failure of all the Test scripts with which Shared OR is attached.

Concurrent issue, Only one user can edit the Shared OR at a


time, so in multiple user team working on same Shared OR,
person has to wait to add objects to OR until other person
closes, otherwise itll come in read only mode.

Incase we are running UFT in update mode, it is not


possible for Shared OR, as it comes in read only mode in
object repository window

I am not very sure whether it has any performance


implications as it is a single file shared across multiple projects.

2) Test Resources (TS) tab is used to store various resources


available for automation. Basically it acts as a shared store
house, like we deposit our money in bank. So various resources
that can be saved in TS, can be Test Scripts, OR, Data files,
Recovery scenarios, Test cases, Library functions.
Please add incase I am missing something.
3)Method1:RepositoriesCollection.Add("Path of OR")
Method2:Using Automation Object Model
4)Refer the link Test Batch Runner
Interview Questions (Part-4)
These below questions test your real approach in using QTP, interviewer use this to judge
whether you have really worked on this tool. Hope it helps you people.
1. Why your company went for automation and how QTP was shortlisted from all the tools?
2. Can you please share any challenging situation faced while using QTP and how you
overcome it?
3. How many applications you have automated, or lines of code you have written?
4. Please explain any situation where QTP failed to automate?
5. How you can make scripts that are easy to maintain?
Interview Questions (Part-5)
1. Which all the Operating Systems are supported by UFT/QTP?

2. Does QC run only on Windows OS?


3. Can you please explain which all browsers are supported by UFT?
4. Does QTP support database testing?
5. Can we import test cases from HP-Sprinter into UFT?

Answers to Part-5
I am giving just giving brief pointers, incase more details are required please Contact Us
1.Windows
2. Windows, Solaris, Linux
3.IE,Firefox,Chrome
4.Yes, using Database checkpoint
5.Yes

PART-6
In one of the interview i was asked to write test cases on "Credit Card", thought of sharing with testing
community , please feel free to add and extend the cases.
Physical appearance/Usability:

Test the color and size of the card

Bank name/type of card(Titanium,platinum)

Credit card number (16 digit)

Card provider (Master card/Visa card)

Name of the user on card, validity dates

24 hour customer support numbers

Magnetic strip should be at proper place

Material used for card should not be harmful

Credit card width, height so that it can be swiped into card reader machine

Functionality:

Credit card asks for pin after swiping into card reader

In case credit limit for month/day has reached no transaction is possible

On complete transaction, bank database is getting updated

On debit of amount phone message is received

In case card is blocked by user, it should not work

Expired card/broken strip doesn't initiate transaction

Incase card has chip facility then both dip and swipe should work

Online transaction, using paypal flow, try negative cases

Invalid credit card number/Expiry date

Session expiry

PART-7
1. How many types of Array are there?
2. Can we redefine the index of an Array?
3. What is the difference between an Array and Dictionary Object?
4. How can we get lower index and upper index of an Array?
5. If Array is of index 10, how many variables it can store?
6. What will be the output of following code :Dim arr(3)
For i = 0 to 3
arr(i) = i+1
Next

Msgbox arr(4)
7.Write a code for assigning values to a 2-D array?
8.Why we use "Preserve" keyword in Array?
=======
Today we are sharing some of the frequently asked manual interview questions:-

1.

Difference between testing and QA?

2.

What is the difference between System testing and End-End testing?

3.

What is the significance of V-model in testing?

4.

Difference between Sanity and Smoke Testing?

5.

Please explain Verification and Validation?

6.

Can a test case have multiple Test-scenario's?

PART-9
1.What is the difference between Action and Function in UFT?
2.Explain the difference between image and Bit map check point?
3. Difference between verification and validation ?
4.Methods available in Reporter utility object?
5.How to get last four digits of "UFTHELP"?
6.Regression v/s Re-Testing?

Hints:1.Action is a concept of UFT while Function is related to VBscripting.


2.Image checkpoint is used to check the Property Values of an image(like alt),Bitmap
checkpoint is used to check an area of a web page or an application after capturing it as a

bitmap so that it can be compared with the expected and the actual bitmap
3. Checking that a "shoe" is of given size = Verification , Wearing shoe and checking the size
is validation
4.ReportEvent, ReportNote
5.Using vb scripting "Right" function:- Right(string,4)
.Why we use Automation Testing?
2.How we can Merge Object Repositories in QTP?
3.Please tell me the steps for connecting QTP with Database?
4.How we can copy text from Notepad and Paste in Excel?
5.What type of Framework you have worked?
6.Can we implement "Modular" Framework in "Keyword Driven" Framework?
7.Explain the latest Bug you have logged using QTP?

Hints:1.Speed,Reliability, Human resource independent accurate, Comprehensive ,Regression is


easy
2.Object Repository Manager, have tool called "Merge Repositories"
It has been a while for any post on "UFTHelp". To kick start the flow again, today we
thought of sharing some more basic questions regarding UFT/QTP.
We hope it'll definitely help the testing community.Please share your feedback or your
experiences.
1.Why we use "PathFinder" object in QTP?
2.What are regular expressions in QTP?
3.Explain "QcUtil" object ?
4.How we can achieve synchronization in QTP?
5.Meaning of Descriptive Programming?

6.Please give one liner for COM and WSH in context with QTP/UFT?
7.Explain scenario's where we can avoid Automation?
8.Why we use Object Spy?
9.Difference between various recording modes in QTP/UFT?
Hints:1.To get the "Absolute Path".
3.It is a Utility object which is used in OTA (Open test Architecture)
4.Wait, WaitProperty,Exist, Sync(Only Web),File-Settings-Run Tab-Increase
object synchronization
7.Usability Testing, ASAP testing, No ROI , Task is not Repetitive

Using DOM, XPath & CSS for Object


Identification in QTP Part 2
Posted: November 24, 2011 | Author: unmesh | Filed under: QTP, Test Automation, Testing | Tags: CSS, DOM, HTML
DOM, QTP, Web Testing, XPath |14 Comments

XPath is another important Web Object Identifier introduced in QTP 11. It is one of the widely used
identification strategy in open source tools. In this tutorial we will understand using XPath for locating Web
objects in your application with QTP.
Introduction to XPath
XPath is used for locating nodes in an XML document and it can also be used for locating HTML
elements in XHTML. XPath opens up all sorts of new possibilities for locating complex & dynamically
rendered elements.
Awkwardly, developers not always follow best practices or testability guidelines while building the
applications. XPath comes to your help when you dont have a suitable id or name attribute for the
element you wish to identify. You can use XPath to either identify the element in absolute terms or relative
to an element that does have an id or name attribute. XPath locators can also be used to specify elements
via attributes other than id and name.
Using XPath for Web Object Identification

QTP 11 has added XPath Object Identification Property to all Test Objects in Web Add-In. QTP offers two
ways to use XPath, you can either instruct QTP to record Automatic XPath by settings Options in Tools
menu or you can specify User Defined XPath in xpath Property.
You can also enable and use xpath Property in Object Repository or in Descriptive Programming. In
following example a direct XPath query is used to identify Search Text Box on Google:

Browser("title:=Google").Page("title:=Google").WebEdit("xpath:=//input").Set "What
is XPATH"

In above example we used //input to identify the Search Text Box. Using // in XPath query is called greedy
query as it parses the entire HTML DOM until it finds the desired element. This way is useful when
objects are dynamically positioned; however it takes certain amount of time to find the element.
However if you are certain about position of the desired element, you can use a direct XPath query by
using single /, however please make you sure that the HTML is first node in your query. Following
example shows direct XPath query for User Name Text Box on Gmail Home Page:

Browser("title:= Gmail: Email from Google").Page("title:= Gmail: Email from


Google").WebEdit("xpath:=/html/body/div/div[2]/div/div/form/label/input").Set "myname"

Direct XPath query will find the element quicker, however if application GUI is going to change, it may fail
if the element is moved into a different area of the Page.
Using Element Attributes in XPath
We can use various element attributes such as ID, Name, Value, Type etc. to identify element in following
way:

//element [@attribute='attribute value']

In following example, ID attribute is used to identify User Name Text Box on Gmail Home Page:

Browser("title:= Gmail: Email from Google").Page("title:= Gmail: Email from


Google").WebEdit("xpath:=//input[@id='Email']").Set "myname"

We can also use combination of attributes in XPath query so that we can try to make the element more
unique for identification:

//element[@attribute='attribute value' and @attribute='attribute

value']

In following example, we will identify and check Stay signed in Checkbox on Gmail Home Page:

Browser("title:= Gmail: Email from Google").Page("title:= Gmail: Email from Google").


WebCheckBox("xpath:=//input[@id='PersistentCookie' and @type='checkbox']").Set "ON"

Identifying Elements using partial match on Attribute values


We can use XPath functions such as contains(), starts-with() & ends-with() to perform partial match on
attribute values while locating the elements. This is useful when developers use Dynamic IDs or Name
attributes while rendering the elements on a Page. This is commonly used in AJAX applications &
frameworks.

//element[starts-with(@attribute,attribute partial value')]

//element[contains(@attribute,attribute partial value')]

//element[ends-with(@attribute,attribute partial value')]

In following example, developers have assigned dynamic IDs for all the input elements in following way:

1
2
3

<div id='login_area'>
<input type='text' id='text_1'>
</div>

We can use either starts-with() or contains() function to identify this object in following way:

Browser("title:= Test App").Page("title:= test App").WebEdit("xpath:=//div[@id='login_a


'text_')]").Set "somevalue"

Browser("title:= Test App").Page("title:= test App").WebEdit("xpath:=//div[@id='login_a


'text_')]").Set "somevalue"

Identifying Elements using Text Contents

Locating elements by the text they contain can be quite useful. To identify elements, we need to
usetext() function in XPath query. This will match the entire contents of the element.

//element[text()='inner text']

In following example, we will use text() function to identify the Create an account link on Gmail Home
Page:

Browser("title:= Gmail: Email from Google").Page("title:= Gmail: Email from Google").Li


account']").Click

We can also use XPath functions contains(), starts-with() or ends-with() for matching partial text.

//element[contains(text(),'text value')]

Exmaple:

strLotsOfStorageMessage = Browser("title:= Gmail: Email from Google").Page("title:= Gma


Google").WebElement("xpath:=//p[contains(text(),'Over')]").GetROProperty("innerText")

Identifying Elements with XPath Axes


In simple terms XPath Axes helps to identify elements based on elements relationship with other
elements in a document. For more information, there is a nice tutorial available on W3Schools on
XPath & XPath Axes.
For example in an e-commerce web application, we want to select and add items to shopping cart.
However the items are listed in a table dynamically with complex HTML structure. Following figure shows
the structure of the table:

Shopping Cart Page

The textbox to enter the Quantity and image to add item was buried under layer of div elements inside a td
element in a table. The ids for these elements were generated dynamically and it is difficult to add an item
dynamically from the test script. Here is html code for Quantity textbox:

For Product 1

<input type="text" id="count_670756" value="" maxlength="3" size="3"


name="qty">

For Product 2

<input type="text" id="count_670759" value="" maxlength="3" size="3"


name="qty">

As you can see in the above code, we cannot rely on id attribute as it changes every time page is
refreshed and secondly name of textbox is not unique.
We need to find a unique way to identify a Product in the table. There are two columns which contain
unique values namely Product & Article column. However Article column contains primary key from the
database so it is highly recommended to use this value as basis to identify the product. We can also use
Product column otherwise. Following XPath Query will identify the cell containing the specified Article
using XPath functions contains() & text():

xpath:=//td[contains(text(),'0002')]

Now we need to find the cell which contains the elements. Here we will use following-sibling axis and
find the third cell from the current cell. Following query will return the cell containing Quantity & Add to
cart image:

xpath:=//td[contains(text(),'0002')]/following-sibling::td[3]

In next step we need to get the actual elements which are located inside the layer of div elements. Here
we need to use descendent axis to find the child elements in the cell:

xpath:=//td[contains(text(),'0002')]/followingsibling::td[3]/descendant::div[2]/input[@name='qty']

2
3

xpath:=//td[contains(text(),'0002')]/followingsibling::td[3]/descendant::div[3]/input[@name='add']

We can remove the nth element, or element Index to make this XPath query more flexible in following
way:

1
2

xpath:=//td[contains(text(),'0002')]/followingsibling::td/descendant::div/input[@name='qty']
xpath:=//td[contains(text(),'0002')]/followingsibling::td/descendant::div/input[@name='add']

VBScript code to enter quantity for an Item and add selected Item to the Shopping Cart in QTP:

1
2

Browser("title:= ShopX").Page("title:= ShopX ").WebEdit("xpath:=//td[contains(text(),'0


sibling::td/descendant::div/input[@name='qty'").Set "10"

Browser("title:= ShopX").Page("title:= ShopX ").Image("xpath:=//td[contains(text(),'000


sibling::td/descendant::div/input[@name='add']").Click

These actions will be used to add multiple items in various test cases. We need to make these actions
more generic and remove the hardcoded Article Id. Following example shows user defined function in
QTP for above steps:

Public Function fnAddItemToShoppingCart(ByVal strArticleID, ByVal strQTY)

2
3
4
5
6

Browser("title:= ShopX").Page("title:= ShopX ").WebEdit("xpath:=//td[contains(text(),'"


sibling::td/descendant::div/input[@name='qty'").Set strQTY

Browser("title:= ShopX").Page("title:= ShopX ").Image("xpath:=//td[contains(text(),'" &


sibling::td/descendant::div/input[@name='add']").Click

End Function

However while using XPath we need to consider the fact that these locators are dependent on structure of
the page and the layout of the elements. Any changes to the structure or layout will affect the locators and
tests will result into failures.

You might also like