简体   繁体   English

如何检查webtable中的列是否被完全删除?

[英]How to check whether a column was deleted completely in a webtable?

How to check whether a column was deleted completely in a webtable using VB script?如何使用VB脚本检查webtable中的列是否被完全删除?

I've created a row in a webtable and deleted it.我在 webtable 中创建了一行并将其删除。 I'd like to check whether the column is deleted from that webtable or not.我想检查该列是否已从该 webtable 中删除。 I've written a script and having a tough time to write the logic.我写了一个脚本,但很难写出逻辑。 I can get complete row count from a webtable and can loop through one by one.我可以从网络表中获得完整的行数,并且可以一一循环。 But how to check whether that column was deleted from the webtab?但是如何检查该列是否已从 webtab 中删除?

rowCount = SwfWindow(obj).SwfTable(tbl).RowCount 
For i = 0 To rowCount - 1 
    names = SwfWindow(obj).SwfTable(tbl).GetCellData(i, 1)       
    If  names = mycolname  'mycolname is the name of the column deleted  Then
        SwfWindow(obj).SwfTable(tbl).ClickCell i,1  
        Print "col name is present in the table"
        Exit for
    else
        Print "col name is deleted completely from the table"   
    End If
Next

How do you want to identify the column?你想如何识别列? Probably by name.应该是名字吧。 (The code shown in the question indexes by numeric index.) (问题中显示的代码按数字索引索引。)

It then depends on the webtable´s structure:然后它取决于webtable的结构:

There is a WebTable runtime property returning the name of all columns in a string separated by a semicolon;有一个 WebTable 运行时属性,返回以分号分隔的字符串中所有列的名称; iterate over the components of this string and query their names in the loop.遍历此字符串的组件并在循环中查询它们的名称。 If you find the to-be-deleted column in the process, it is still present, if not, it´s deleted.如果您在该过程中找到要删除的列,则它仍然存在,如果没有,则将其删除。

See http://www.sqaforums.com/forums/hp-unified-functional-testing-uft-mercury-quicktest-pro-qtp/148239-qtp-function-web-table-get-column-number-giving-column-name.html for an example.请参阅http://www.sqaforums.com/forums/hp-unified-functional-testing-uft-mercury-quicktest-pro-qtp/148239-qtp-function-web-table-get-column-number-giving-column -name.html为例。

Sometimes, the table is organized a bit different, and the getROProperty call returns garbage.有时,表的组织方式略有不同,并且getROProperty调用返回垃圾。 Then, you usually find the column names as cell data in row 1. There, you would need to iterate over the columns and use getCellData to look at the column name.然后,您通常会在第 1 行中找到作为单元格数据的列名。在那里,您需要遍历并使用getCellData查看列名。

As pointed out by @TheBlastOne, the table you see in the AUT (application under test) does not necessarily tell the whole truth about how it is actually structured.正如@TheBlastOne 所指出的,您在 AUT(被测应用程序)中看到的表格并不一定能说明其实际结构的全部真相。 The following is a neat trick, which should work for both WebTable and swfTable, to be able to see the actual structure of a table:下面是一个巧妙的技巧,它应该适用于 WebTable 和 swfTable,以便能够查看表的实际结构:

  1. When you have both the AUT and QTP open, click the "Record" button in QTP当你同时打开 AUT 和 QTP 时,点击 QTP 中的“录制”按钮
  2. Choose to start recording on the open application选择在打开的应用程序上开始录制
  3. On the toolbar menu in QTP, select "Insert" --> "Checkpoint" --> "Standard Checkpoint" and click on the table in the AUT在QTP中的工具栏菜单上,选择“插入”-->“检查点”-->“标准检查点”,点击AUT中的表格

A new window should now have opened, which, among other things, shows you exactly how the table is structured, ie row indexes and/or names, column indexes and/or names, etc.现在应该打开了一个新窗口,除其他外,它会准确显示表的结构,即行索引和/或名称、列索引和/或名称等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM