1、ToString() : Returns a string that represents the current test object.

Example

The following example uses the ToString method to generate a report detailing the dimensions of a MainFrame test object.

Sub ReportRectangle(obj)

x = obj.GetTOProperty("abs_x")

y = obj.GetTOProperty("abs_y")

w = obj.GetTOProperty("width")

h = obj.GetTOProperty("height")

Reporter.ReportEvent micDone, obj.ToString() & " dimensions", "The Virtual object " & obj.ToString() & " is defined using the following dimensions: " & x & ", " & y & ", " & x+w & ", " & y+h

End Sub 

'Sample usage
ReportRectangle Browser("XXXX平台").Page("XXXX平台").Frame("mainFrame")

2、Generate a Report Detailing the Content of an Edit Box

Function VerifyTextPropertyNotEmpty(obj) 

   Text = obj.GetROProperty("text") 

   If Text = "" Then 

       Reporter.ReportEvent micFail, obj.ToString() & " Text Verification", "Verification Failed. " & obj.ToString() & " does not have a text value." 

    VerifyTextPropertyNotEmpty = False 

   Else 

       Reporter.ReportEvent micPass, obj.ToString() & " Text Verification", "Verification Passed. The " & obj.ToString() & " contains the following text: " & Text 

       VerifyTextPropertyNotEmpty = True 

   End If 

End Function 

3、Verify the Number of Items in a List.

Sub CheckProperty_Example() 

'The following example uses the CheckProperty method to verify the 

'number of items in a WebList. Note that if the original count 

'is not equal to 15, an error message is displayed in the Test Results. 

Browser("Fill-Out Form Example").Page("Fill-Out Form Example").WebList("what-to-do").CheckProperty "items count", 15, TimeLimitation 

Item_Count = Browser("Fill-Out Form Example").Page("Fill-Out Form Example").WebList("what-to-do").GetROProperty("items count") 

If Item_Count = 15 Then 

   'Remove one item from the list 

    Browser("Fill-Out Form Example").Page("Fill-Out Form Example").WebButton("Remove Item From List").Click 

    'Check if the item was removed from the list 

    Browser("Fill-Out Form Example").Page("Fill-Out Form Example").WebList("what-to-do").CheckProperty "items count", 14, TimeLimitation 

Else 

    Reporter.ReportEvent micFail, "Number Of List Items", "The item count in the list should be 15, not " & Item_Count & "." 

End If 

End Sub 

QTP学习笔记之—VBS的更多相关文章

  1. QTP学习笔记--Excel数据源

    直接读取Excel表格的function摘自此处http://www.51testing.com/html/40/307440-827863.html  特此感谢! Excel作为QTP自动化测试的数 ...

  2. QTP学习笔记--define new test object

    目前在测的系统里,有图片控件,图片源都是一样的,链接地址不同(链接地址是动态变化的,不适合作为属性). QTP的识别机制是根据Index来的,复制对象之后更改Index的属性方法无效,采用define ...

  3. QTP学习笔记---datatable应用

    DataTable应用1.定位数据行 DataTable.GetSheet() 2.获取当前行 GetCurrentRow3.获取指定行的值 getValueByRow = DataTable.Get ...

  4. QTP学习笔记1

    1.将变量值写入datatable/ 从datatable中取值赋给变量 DataTable("列名","sheet名") = 变量名 变量名 = DataTa ...

  5. 【工作笔记】BAT批处理学习笔记与示例

    BAT批处理学习笔记 一.批注里定义:批处理文件是将一系列命令按一定的顺序集合为一个可执行的文本文件,其扩展名为BAT或者CMD,这些命令统称批处理命令. 二.常见的批处理指令: 命令清单: 1.RE ...

  6. php入门学习笔记

    学习笔记[6.5-6.13] 1.常用命令 打开数据库格式: mysql -h主机地址 -u用户名 -p 重启nginx:sudo /etc/init.d/nginx restart或者service ...

  7. js学习笔记:webpack基础入门(一)

    之前听说过webpack,今天想正式的接触一下,先跟着webpack的官方用户指南走: 在这里有: 如何安装webpack 如何使用webpack 如何使用loader 如何使用webpack的开发者 ...

  8. PHP-自定义模板-学习笔记

    1.  开始 这几天,看了李炎恢老师的<PHP第二季度视频>中的“章节7:创建TPL自定义模板”,做一个学习笔记,通过绘制架构图.UML类图和思维导图,来对加深理解. 2.  整体架构图 ...

  9. PHP-会员登录与注册例子解析-学习笔记

    1.开始 最近开始学习李炎恢老师的<PHP第二季度视频>中的“章节5:使用OOP注册会员”,做一个学习笔记,通过绘制基本页面流程和UML类图,来对加深理解. 2.基本页面流程 3.通过UM ...

随机推荐

  1. 各种模板(part 1)

    GCD: int gcd(int a,int b) { ?a:gcd(b,a%b); } 快速幂: void work(int x,int y) //x^y { ; ) { ==) ans=ans*x ...

  2. s2 devMode cmdshell

    s2 devMode cmdshell   仅支持批量验证,命令执行 链接:http://pan.baidu.com/s/1sl7tgRV 密码:wud8 也可以通过outscan一键获取,之后导入t ...

  3. js取整函数

    1.丢弃小数部分,保留整数部分parseInt(5/2) 2.向上取整,有小数就整数部分加1 Math.ceil(5/2) 3,四舍五入. Math.round(5/2) 4,向下取整 Math.fl ...

  4. [转]Linux命令的返回值

    Linux命令的返回值 对于某些监测脚本和探测命令蛮有用的: 在 Linux 下,不管你是启动一个桌面程序也好,还是在控制台下运行命令,所有的程序在结束时,都会返回一个数字值,这个值叫做返回值,或者称 ...

  5. .gitignore的多级目录配置

    在子目录下仍然可以建立.gitignore文件以用于忽略子目录的文件

  6. python命令行解释器 argparse

    一: argparse介绍 1.  argparse argparse,它是Python标准库中推荐使用的编写命令行程序的工具 parser = argparse.ArgumentParser()  ...

  7. js 防止页面后退的方法

    //防止页面后退 history.pushState(null, null, document.URL); window.addEventListener('popstate', function ( ...

  8. Python set集合类型操作总结

    Python中除了字典,列表,元组还有一个非常好用的数据结构,那就是set了,灵活的运用set可以减去不少的操作(虽然set可以用列表代替) 小例子 1.如果我要在许多列表中找出相同的项,那么用集合是 ...

  9. Mysql大量数据快速排序方案

    日常开发中经常需要对数据进行排序,通常可以讲数据库中的数据获取到后通过程序在内存中进行排序,但是这样排序需要将排序内容从数据库中查询到内容,同时使用程序算法进行排序,然后将排序结果更新入数据库,这样排 ...

  10. winform中ComboBox实现text和value,使显示和值分开,重写text和value属性

    winform的ComboBox中只能赋值text,显示和值是一样的,很多时候不能满足根本需要,熟悉B/S开发的coder最常用的就是text和value分开的,而且web下DropDownList本 ...