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. 前端学习 第七弹: Javascript实现图片的延迟加载

    前端学习 第七弹: Javascript实现图片的延迟加载 为了实现图片进入视野范围才开始加载首先: <img    src="" x-src="/acsascas ...

  2. ExtJs 学习之开篇(-)之define

    Ext.onReady(function(){    /**     * test1,声明一个类,定义类中的方法     */ Ext.define("demo.Demo",{   ...

  3. javascript跨域、iframe跨域访问

    1.window 对象 浏览器会在其打开一个 HTML 文档时创建一个对应的 window 对象.但是,如果一个文档定义了一个或多个框架(即,包含一个或多个 frame 或 iframe 标签),浏览 ...

  4. linux kernel的中断子系统 softirq

    linux kernel的中断子系统之(八):softirq http://www.wowotech.net/irq_subsystem/soft-irq.html http://www.ibm.co ...

  5. python raw String 获取字符串变量中的反斜杠

    常用的获取raw string的方式为: >>>r'\n' \n 不能用在字符串变量中,获取字符串变量中的反斜杠如下: tab = '\n' >>>tab.enco ...

  6. Python os._exit() sys.exit()

    os._exit()会直接将python程序终止,之后的所有代码都不会继续执行. sys.exit()会引发一个异常:SystemExit,如果这个异常没有被捕获,那么python解释器将会退出.如果 ...

  7. jquery筛选器

    1.过滤   eq(index|-index)  获取当前链式操作中第N个jquery对象,正数从0开始,负数从-1开始. first 获取当前链式操作中第1个jquery对象 last 获取当前链式 ...

  8. window.showModalDialog的简单实践

    Super.jsp - 父窗口 <%@ page language="java" import="java.util.*" pageEncoding=&q ...

  9. php mysql 一个查询优化的简单例子

    PHP+Mysql是一个最经常使用的黄金搭档,它们俩配合使用,能够发挥出最佳性能,当然,如果配合Apache使用,就更加Perfect了. 因此,需要做好对mysql的查询优化.下面通过一个简单的例子 ...

  10. 将页面打印成excel

    在servlet中调用 try { File fileWrite = new File("D:/Write.xls"); fileWrite.createNewFile(); Ou ...