You are on page 1of 7

5/8/2018 QTP Tutorials & Interview Questions: QTP WebTable Object

QTP Tutorials & Interview Questions


(now includes most useful Software Testing Questions)

SQL Saturday, November 21, 2009


If you enjoy reading this QTP blog, please help
QTP WebTable Object multiply the reach of this blog by clicking on +1
button

WebTable Object is a table containing a


variable number of rows and columns. Search This Blog

We will see most of the methods and


properties of WebTable object with
Reasoning Tests examples below.
QTP PPTs to make your basics strong
Write the below code in a notepad and
save it with .html extention. I saved it as
"a.html" as can be seen in the below
screenshot (in IE). Also note that first
checkbox is named as team and second as
team1 in the code. Most of the examples
below are done using this below table.
QTP - Home

QTP Tutorials

QTP Training PPTs

QTP Scripts

Interview Questions -
Software Testing

QTP - Quick Test


Professional

QTP Testing Process

Test Object Model

QTP Object Repositories

Descriptive Programming
in QTP

Checkpoints in QTP - Quick


Test Professional

QTP Recordings

QTP Parameterize Tests

QTP (Quick Test


Professional) Keyword View

Actions in QTP 9 (Quick


Test Professional)

VBScript in QTP CaptureBitmap Method

Software Automation CaptureBitmap will save a screen capture


Framework of an object as a .png or .bmp image,
depending on the specified file extension at
QTP Sync, Wait, the below mentioned location.
Synchronization New

All About QTP Parameters


Browser("Browser").Page("Page").WebTabl
e("html tag:=TABLE").CaptureBitmap
Difference between Image "C:\Documents and Settings\All
& Bitmap Checkpoint Users\Documents\My Pictures\Sample
Pictures\table.png"
Action input & output
Parameters You can write the above used browser and

http://qtp.blogspot.in/2009/11/qtp-webtable-object.html 1/7
5/8/2018 QTP Tutorials & Interview Questions: QTP WebTable Object
page objects in descriptive programming
Capturing Background also. If you run the above line on the
Color in QTP
example table, it will take a screenshot of
the WebTable and save it as a .png file in
Object Hierarchy in QTP
Sample Pictures folder.
QTP Function Libraries
Check Method
QTP GetTOProperties,
GetROProperty Checks whether the actual value of an item
matches the expected value. As an
QTP History
example
Software Test Automation
Questions
Make sure that both IE with that table and
QTP are open .
Software Testing Click record.
Templates Go to Insert (Menu) -> Checkpoint->
Standard Checkpoint.
Online QTP Training Course Click on checkbox (QTP checkbox). Make
sure you click on checkbox and not on text
Verification & Validation
"QTP".
Questions
Object Selection: Checkpoint Properties
Database Testing - Tips & Window opens with "WebCheckBox: team"
Resources highlighted. Click OK.
Checkpoint Properties window opens.
Resume - How To Uncheck all checkboxes except "Checked".
Click OK.
Negative Testing Examples
Click Stop in order to stop recording.
SDLC Methods &
Methodologies
It recorded this below line :
Browser("Browser").Page("Page").WebChe
Object Repository ckBox("team").Check CheckPoint("team")
Interview Questions
And I changed it to:
Testing in Agile a=
Browser("Browser").Page("Page").WebChe
Defect Tracking Tools
ckBox("name:=team").Check
Reviewed
(CheckPoint("team"))
Game Testing - Tips & msgbox a
Resources
Now you can run the above two lines and
Data Driven Framework - see the value of a. If the QTP checkbox is
An Example checked it will show True else False.

Keyword Driven
Above you can use Descriptive
Framework - Functional
Programming for all objects also. I have
21 Test Management Tools used Descriptive Programming only for
Reviewed WebCheckBox object.

Keyword Driven CheckProperty Method


Framework - (Operational)
Checks whether the specified object
Keyword Driven
property achieves the specified value
Framework - (Operational
(Data & Keywords are within the specified timeout. Here we are
separate)) checking if the WebCheckbox object’s
checked property achieves a value of 1 i.e.
Keyword Driven if checkbox is checked and in our case it
Framework - (Operational - will show True as both checkboxes are
Web based) checked. 20 is the time in milliseconds.

Difference - Sanity &


a=Browser("Browser").Page("Page").WebC
Smoke Testing
heckBox("name:=team").CheckProperty
SQL Injection ("checked", 1, 20)
msgbox a
Mobile Application Testing
- FAQs ChildItem Method

Interview Questions - QA Returns a test object from the cell by type


Lead / Manager
and index. Here it is returning QTP
checkbox and we are clicking it afterwards.

Set a =
Browser("Browser").Page("Page").WebTabl
e("html tag:=TABLE").ChildItem(2, 1,
"WebCheckBox", 0)
a.click

ChildItemCount Method

http://qtp.blogspot.in/2009/11/qtp-webtable-object.html 2/7
5/8/2018 QTP Tutorials & Interview Questions: QTP WebTable Object

Returns the number of objects of a specific


type in the specified cell. Here it is
returning the count of checkboxes. 2 is the
row and 1 is the columns below.

a=Browser("Browser").Page("Page").WebT
able("html
tag:=TABLE").ChildItemCount(2, 1,
"WebCheckbox")
msgbox a

ChildObjects Method

Returns the collection of child objects


contained within the object. Here it shows
the names of all the child objects one by
one in a message box.

Set a =
Browser("Browser").Page("Page").WebTabl
e("html tag:=TABLE").ChildObjects

msgbox a.count

For i=0 to a.count-1


msgbox i & " " &
a(i).getroproperty("name")
Next

Click Method

Clicks the object. Here it is clicking the first


checkbox.

Browser("Browser").Page("Page").WebTabl
e("html
tag:=TABLE").WebCheckBox("name:=tea
m").Click

ColumnCount Method

Returns the number of columns in the


table. Below "2" is the row number.

msgbox
(Browser("Browser").Page("Page").WebTab
le("html tag:=TABLE").ColumnCount(2))

FireEvent Method

Triggers an event. Here it is firing the


“onclick” event for first checkbox.

Browser("Browser").Page("Page").WebTabl
e("html
tag:=TABLE").WebCheckBox("name:=tea
m").FireEvent "onclick"

GetCellData Method

Returns the text contained in the specified


cell.

msgbox
(Browser("Browser").Page("Page").WebTab
le("html tag:=TABLE").GetCellData(1,1))

GetROProperty Method

Returns the current value of the test object


property from the object in the application.
Checks the checked property of first
checkbox and returns it.

msgbox
Browser("Browser").Page("Page").WebTabl

http://qtp.blogspot.in/2009/11/qtp-webtable-object.html 3/7
5/8/2018 QTP Tutorials & Interview Questions: QTP WebTable Object
e("html
tag:=TABLE").WebCheckBox("name:=tea
m").GetROProperty("Checked")

GetRowWithCellText Method

Returns the number of the first row found


that contains a cell with the specified text.
See what the below line shows in case of
our example WebTable.

msgbox
Browser("Browser").Page("Page").WebTabl
e("html
tag:=TABLE").GetRowWithCellText("Hello")

GetTOProperties Method

Returns the collection of properties and


values used to identify the object. Below
code runs for first checkbox and return its
name and value as seen below in the
screenshot.

Set a=
Browser("Browser").Page("Page").WebTabl
e("html
tag:=TABLE").WebCheckBox("name:=tea
m").GetTOProperties

msgbox a.count

For i=0 to a.count-1


msgbox (a(i).Name & " " & a(i).value)
Next

GetTOProperty Method

Returns the value of the specified property


from the test object description. Clearly
understand the difference between this and
above method. Below line will show "team"
in the message box when run.

msgbox
Browser("Browser").Page("Page").WebTabl
e("html
tag:=TABLE").WebCheckBox("name:=tea
m").GetTOProperty("name")

Output Method

Retrieves the current value of an item and


stores it in a specified location. Below
example shows retrieving the value and
storing it in runtime data table.

Make sure that both IE with that table and


QTP are open.
Click record.
Go to Insert (Menu) -> Output Value->
Standard Output Value.

http://qtp.blogspot.in/2009/11/qtp-webtable-object.html 4/7
5/8/2018 QTP Tutorials & Interview Questions: QTP WebTable Object
Click on checkbox (QTP checkbox). Make
sure you click on checkbox and not on text
"QTP".
Object Selection: Output Value Properties
Window opens with "WebCheckBox: team"
highlighted. Click OK.
Output Value Properties window opens.
Uncheck all checkboxes except "Checked".
Click OK.
Click Stop in order to stop recording.

It recorded this below line:


Browser("Browser").Page("Page").WebChe
ckBox("name:=team").Output
CheckPoint("team_3")

And I changed it to:


Browser("Browser").Page("Page").WebChe
ckBox("name:=team").Output
CheckPoint("team_3")
msgbox a

I just added the message box line so that


you can see the runtime value of "QTP
Checkbox" in the Global data sheet,
otherwise there is no need of message
box.
Now you can run the above two lines and
see the value of checkbox in Global data
sheet. If the QTP checkbox is checked it
will show 1, else 0.

See DataTable in the below screenshot:

RowCount Method

Returns the number of rows in the table.

msgbox
Browser("Browser").Page("Page").WebTabl
e("html tag:=TABLE").RowCount

ToString Method

Returns a string that represents the


current test object. Below example shows
the name of the test object (checkbox) and
its type.

a=Browser("Browser").Page("Page").WebC
heckBox("name:=team").ToString
msgbox a

http://qtp.blogspot.in/2009/11/qtp-webtable-object.html 5/7
5/8/2018 QTP Tutorials & Interview Questions: QTP WebTable Object

WaitProperty Method

Understand WaitProperty.

Submit Method

Submits a form. This method simulates


pressing the Enter key, while the focus is
on the object specified in the statement.

Suppose this page is open:


http://newtours.demoaut.com/

Now if we run this below code in QTP:

Browser("name:=Welcome: Mercury
Tours").Page("title:=Welcome: Mercury
Tours").Image("alt:=Sign-In").Submit

Then this below page opens:


http://newtours.demoaut.com/mercurysignon.php

Drag, Drop Method

Drag & Drop Example

SetTOProperty Method

Understand GetTOProperty &


GetTOProperties above and here and try
SetTOProperty yourself.

Exist Property

Checks whether the object currently exists


in the open application.

a=Browser("Browser").Page("Page").WebC
heckBox("name:=team").Exist

If a="True" Then
msgbox "True"
else
msgbox "False"
End If
msgbox a

Object Property

Accesses the internal methods and


properties of the object. The Object
property for Web objects is supported only
when running steps on Internet Explorer.
It is not supported when working with
Netscape Browser or Mozilla Firefox. Below
example accesses the checkbox object and
then performs click method on it.

set
a=Browser("Browser").Page("Page").WebC
heckBox("name:=team").Object
a.click

Posted by Sachin Dhall at 10:11:00 AM

http://qtp.blogspot.in/2009/11/qtp-webtable-object.html 6/7
5/8/2018 QTP Tutorials & Interview Questions: QTP WebTable Object
Newer Post Home Older Post

Powered by Blogger.

http://qtp.blogspot.in/2009/11/qtp-webtable-object.html 7/7

You might also like