Facebook

What's New @ QTPSudhakar New QTP Training Batches @ MindQ Systems by QtpSudhakar
WeekDays :
Starting from December 2nd 7.30AM to 9.00AM
WeekEnd :
Starting from December 6th 9.00AM to 2.00PM Click Here to Register.

Cracking the QTP interview - Paperback Book

A new book "Cracking the QTP interview" authored by Sudhakar Kakunuri. This book is a paperback and it was published by TATA McGrawHill. It consists of 400 frequently asked questions with detailed answers for all topics including QTPScripting and VBScripting. Also a framework explained with step by step and you can easily develop by following the steps provided in the book. A list of Framework expected Q&A's are provided... Read More
MRP: Rs.295/-

Buy This Book From
BookAdda
FlipKart BuyBooksIndia

Thursday, February 12, 2009

Working with Webtable Object

What is a web table object?
Tables are one of the primary design tools for HTML documents. Tables allow for greater control over page layout, allowing creation of more visually interesting pages. Tables are also used to set apart sections of documents, such as in sidebars, navigation bars, or framing images and their titles and captions. Tables have literally changed the look of the Web page. Originally, tables let people present data in a column format. Designers quickly figured out ways to improve the layout of their pages using tables.

A Sample Web Table Object


 Every web table contains data (text data) and child objects in specified cells. When we are working with descriptive programming using QTP, web table object is very useful to get data or to get object information for further activities.
Retrieving data from web table
'**********************************************************************
 
rCount=Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:").RowCount
For r=1 to rCount
cCount=Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:").ColumnCount(r)
For c=1 to cCount
cData=Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:").GetCellData(r,c)
msgbox cData
Next
Next
 
'**********************************************************************

Step1:- Get row count from table
Step2:-Using “For Loop” Get column count for every row.
 Using this row number and column number we can able to identify the cells in a table. To get data from a cell we have to provide row and column numbers of a cell.
Step3:-Get cell data from every cell by providing row and column.
 
Accessing child objects from web table
'**********************************************************************
Set oWebEdit=Description.Create
oWebEdit("micclass").value="WebEdit"
set objList=Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:").ChildObjects(oWebEdit)
 
For objIndex=0 to objlist.count-1
msgbox objlist(objIndex).getroproperty("html id")
Next
 
'**********************************************************************
This example is to access web table child objects using description object. This is a common method to get child objects from any parent level object. Not like other objects web table object is having a special method to get child items from web table cell without using description object.
Accessing child objects from web table cell
'**********************************************************************
 
rCount=Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:").RowCount
 
For r=1 to rCount
cCount=Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:").ColumnCount(r)
For c=1 to cCount
 
oCount=Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:").ChildItemCount(r,c,"WebEdit")
 
For obj=0 to oCount-1
 
set cObject=Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:").ChildItem(r,c,"WebEdit",obj)
 
msgbox cObject.getROproperty("html id")
 
Next
 
Next
 
Next
 
'**********************************************************************

This example to access child objects from web table cell. This method doesn’t require description object support to access child objects from web table. For this we are using Childitem method.
Difference between childobjectchilditem  and Getcelldata methods 
ChildObjects method is to access total child objects from web table object using description object.
Syntax:- object.ChildObjects ([Description])
 
ChildItem method is to access child objects from a web table cell in web table object without using description object.
Syntax:-object.ChildItem (RowColumnMicClassIndex)
 
Getcelldata method is to retrieve data from a web table cell in web table object.
Syntax:-object.GetCellData (RowColumn) 

22 comments:

  1. Very helpful for understanding webtable

    ReplyDelete
  2. Great, could u plz post some more on webtable

    ReplyDelete
  3. great work it is very helpful

    ReplyDelete
  4. Very explanative..

    ReplyDelete
  5. Good Article on WebTable

    ReplyDelete
  6. Hello Sudhakar,
    How can we find a exact value from a web table. Don't know how may rows and columns present in table.
    Is there a best way to search a value, except looping through each row and column every time.
    If we search every cell of a table, it would degrades search performance.

    Thanks,
    Vikas

    ReplyDelete
  7. using regular expression how to find string ="QTP " present or not

    ReplyDelete
    Replies
    1. getRowWithCellText("QTP") will return the row no. if it is not greater than equals to 1 then the text not exist in webtable

      Delete
  8. Hi Sudhakar,
    Its very helpful for testers and learners.
    how to get total single row data from webtable.
    Example: Webtable contains 5 rows and 6 columns.
    I need to get 2 row data of all columns.

    Thanks.

    ReplyDelete
  9. thanks sudhakar..
    it get good unterstanding of web table for me..Thnks

    ReplyDelete
  10. Great post sudhakar..really helpful post to get better understanding of web table methods.
    Keep posting..

    ReplyDelete
  11. hi sudhakar how can we edit/insert data in to webtable

    ReplyDelete
  12. Script on WebTable. Good to understand and Helpful.

    ReplyDelete
  13. Thanks Sudhaker.
    your posts are a great learning resource.
    Kudo.. for ur efforts. Keep posting.

    Regards,
    Azhar

    ReplyDelete
  14. Thanks Sudhakar, Very good source for learning WebTable.

    ReplyDelete
  15. hi sudhakar, how to automate similar childitem in webtable which is randomly changing their position. suppose there are 20 smiliar link but i need to automate 17 number link but it changing randomly to any position between 1 to 20... so pls reply soon

    ReplyDelete
    Replies
    1. Change in position doesn't impact. Use name of the link to compare all 20 objects.

      Delete

All Posts

Show all Object properties without using Object Spy | Deleting Browsing History, Temporary Files, Cookies | How to click on all Google Search Links in all Pages | How to click on all Google Search Links in a Page | VB Script Samples | Working with Recovery Scenarios using Scripting | Virtual Objects in QTP | Diffrent ways to write a statement | Synchronization | Object Identification in QTP | Test Object Model in QTP | Object Repository Types | Managing Object Repositories Using Object Repository Manager | Recording types in QTP | Using Dictionary Objects In QTP | Working with Webtable Object | Descriptive Programming in QTP | Regular Expression for Date and time | Get Runtime Object Properties for a web Object | Get Test Object Properties | Using RunTime Object Properties in QTP | Component, Distributed Component, Automation and Document | QTP Scripting Sample Questions | Advanced VB Script Questions | QTP Version Information Card | WSH Scripting Samples | Working with links Using DOM | File System Object | ListBox Object | Menu Object
Automation Object Model | QTP Tips | How to take screenshot using VBScript? | QTP Scripts Upgrade Tool | Delete Cookies using QTP | How to export/copy KeyWord View Documentation? | Activating a opened window or Browser | VBScript Basics | How to close a windows process through QTP? | How to return multiple values from a function? | What is the limitation of capture screenshot in QTP? | Compare Two bitmaps using QTP | How to update a particulare line in a text file? | Locking and Unlocking Machine in Script Runtime | How to capture the tooltip of a link? | Add and Remove Repositories to an Action In RunTime | When we have to use Update Run Mode? | Use of INI File in QTP | How to Run the analog recorded code which is copied from another test? | What is the maximum size of an Object Repository? | How many action can we create in a single test? | How to connect to SQL without DSN? | What is the use of INI File in QTP? | How to test Slideslow in a page? | How to write DP for an object having many objects in its heirarchy? | How to Convert a number to Currency Format? | how to parameterize links in a web page? | How to Accessing Windows API through vbs? | Advanced VB Script Samples | Executing QTP Scripts on a Remote Computer
Get Objects from Object Repository | Test / Action Iterations | QTP Environment Support Card | Read CSV File Data | Regular Expressions in VBScript | Creating Comments and Action Template | Import CSV File Data in to QTP Datatable | Sample DOM Script On Google Search | Regular Expression in QTP | Sample Script on Descriptive Programming | Object Hierarchies in QTP | Working with Existing Browser Using DOM | Find Hidden Rows in a Table | Preparing and Using Test Data for Automation Test Scenarios | Close latest opened Browser using QTP | Working with Data Table Utility Object | Check whether QTP script is Opened in Read Only Mode? | Quality Center Practice Assignments | All about Validation of Editbox – Part-1 | The Concept of Keyword Driven Framework | How to find Data Type of a Variable? | How to click on dupllicate links in a WebTable? | Difference between Index and Location | All about Validation of Editbox – Part-2 | Click on Object by Holding CTRL Key | Selecting an Environment to Execute Scripts | Descriptive Programming for Virtual Objects | Set Value in EditBox Using DOM | Data-Driven and Keyword-Driven Test Automation Frameworks | Using one Library Functions / Variables in other Library | Features of Object Repository Window and Object Repository Manager | Common DOM Methods & Properties | VBScript Features | Scripting Page Checkpoint