QTP -20 Working with web Tables 与webTable交互
2012-02-06 16:19
411 查看
20 Working with web Tables
The biggest problem is to gain dynamically generated table.20.1 The most important methods to work with table:
*RowCount: Returns the number of rows in the grid. |
*ColumnCount(1) : Returns the number of rows in selected row |
*GetCellData(1,1) : Returns the text contained in the specified cell. GetCellData (Row, Column) |
*ChildItem (Row, Column, MicClass, Index): Returns a test object from the cell by type and index. |
*ChildItemCount (Row, Column, MicClass): Returns the number of objects of a specific type in the specified cell. |
20.2 Access to dynamically generated table, not by OR.
--Using Index: Browser("Browser").Page("Page").WebTable("Index:=3") | |||||||||
--Using Name or HTML ID: Browser("Browser").Page("Page").WebTable("name:=TableName") Browser("Browser").Page("Page").WebTable("html id:=TableId"). | |||||||||
--Using innerText/outerText:(When table row heading text will be constant) #Table caption text goes here
Browser("Browser").Page("Page").WebTable("innerText= Attribute.*value.*Description.*"). #Note: This method is not successful. E.g. Tables nested in table |
20.2 Tables nested in the table
思路:通过innerTextby regular expression的属性,用描述性编程得到所有的tablecollection. 再把单个的webtable用item属性的分离出来。20.3 Using OR to get dynamically generated table
思路:Add“innerText” as recognizing properties, and enter regular expression value “Attribute.*value.*Description.*”, then modifiesthe “index” value.Note: We should run off Smart Identification for thewebTable, as it may lead to incorrect web table selection at runtime.
20.4 Using an object inside the table
思路:OR存有table里面的Object。 写一个方法利用这个object的parentNode方法得到webtable/table。20.5 Clicking inside a WebTable
Method 1: Browser("Browser").Page("Page").WebTable("Name").object.rows(1).Cells(1).Click |
Method 2: (click WebElement in a table cell) sIndex = Browser("Browser").Page("Page").WebTable("Name").object.rows(1).Cells(1).sourceIndex Browser("Browser").Page("Page").WebElement("source_Index:=" & sIndex).Click |
Method 3: 'Use concept of object identification hierarchy, first get Row object then Cell object Set oWebTable = print Browser("Browser").Page("Page").WebTable("Name") Set oRow = oWebTable.WebElement("html tag:=TR", "index:=0") Set oCell = oRow.WebElement("html tag:=TD", "index:=0") oCell.Click |
Method 4: ‘Get 1st cell’s first link: iEdit = Browser("Browser").Page("Page").WebTable("Name").ChildItem(1,1,"Link", 0) |
关键代码如下,其他的如标题的处理在实际项目中需要考虑:
For i = 0 To rowCount dtSheet.SetCurrentRow i+1 cols= webTableObj.ColumnCount(i) For j = 1 To cols dtSheet.GetParameter(j).Value = webTableObj.GetCellData(i, j ) Next Next |
思路:用循环把table的所有值取出来比较即可。
相关文章推荐
- QTP - 26 Working with MS IE browser 与IE 交互
- QTP - 27 Working with HP’s QC 与QC交互
- QTP - 17 Working with APIs 与windows API交互
- QTP - 24 Working with MS Outlook 与outlook交互
- QTP中的WebTable中的GetRowWithCellText方法改进
- QTP -25 Working with MS Word 与word交互
- QTP-21 Working with XML 与XML交互
- QTP-22 Working with Databases 与DB交互
- QTP - 23 (Working with MS Excel) QTP与Excel交互
- Advanced Auto Layout:Working with Self-Sizing Table View Cells
- QTP 获取WebTable单元格中的对象
- QTP处理WebTable
- DCE HOWTO linux netlink working with routing table
- Working with Web Resources in ASP.NET 2.0
- Performing Data Access->Working with Databases in Visual Web Developer 2005 Express Edition
- 2010年7月28日_周三_Working with AJAX capabilities of the Web ADF_overview
- QTP 处理webtable中的数据
- Android: Simplified source code for parsing and working with XML data and web services in Android
- Building a Web Application->Working with Server Controls
- QTP -30 Working with .NET Classes