QTP之CheckProperty Method

转载 2013年12月06日 11:16:37

今天无意在QTP帮助文档中看到CheckProperty和WaitProperty的区别,特摘录如下:

Important Information

If the expected and actual values do not match, an error is reported and the test or component status is changed to failed.

Note: For test run synchronization, or whenever you do not want to fail the test if the expected and actual values do not match, use the WaitProperty method.

You can also use comparison objects to perform more complex value comparisons. For example, you can instruct QuickTest to check whether a specific property value is greater than the specified value.

An example of the syntax required when using a comparison object is: Object.CheckProperty "items count",micGreaterThan(8)

The following comparison objects can be used:

  • micGreaterThan: Greater than; Specifies that QuickTest checks whether the property value is greater than the specified value.
  • micLessThan: Less than; Specifies that QuickTest checks whether the property value is less than the specified value.
  • micGreaterThanOrEqual: Greater than or equal to; Specifies that QuickTest checks whether the property value is greater than or equal to the specified value.
  • micLessThanOrEqual: Less than or equal to; Specifies that QuickTest checks whether the property value is less than or equal to the specified value.
  • micNotEqual: Not equal to; Specifies that QuickTest checks whether the property value is not equal to the specified value.
  • micRegExpMatch: Regular expression; Specifies that QuickTest checks whether the property value achieves a regular expression match with the specified value. Regular expressions are case-sensitive and must match exactly. For example, 'E.*h' matches 'Earth' but not 'The Earth' or 'earth'.

When the types of the expected value and actual value do not match, the comparisons are performed as follows (in this order):

  • Empty values: Empty values may be an uninitialized variable or field (which returns TRUE for the IsNull function in VBscript) or initialized to an empty value (which returns TRUE for the IsEmpty function is VBscript). When trying to compare two arguments when at least one is an empty value, the comparison assumes equality for two uninitialized arguments and for two empty arguments. Any other combination is considered unequal.
    For example:
    dim vEmpty
    Object.CheckProperty “text”,micNotEqual
    (vEmpty)
    will not wait for the timeout (because the 'text' property value is an empty string and the argument passed to micNotEqual is an empty value, and so micNotEqual finds them not equal and returns TRUE).
  • String values: When trying to compare a string value with non-string value, the string value is converted to the non-string type and then compared. If the string value cannot be converted to the non-string type, the comparison assumes the values are not equal.
    For example:
    Object.CheckProperty “text”,micGreaterThan(8) will not wait for the timeout if the 'text' property value is '16' (because micGreaterThan finds 16 to be greater than 8 and returns TRUE), but will wait if the 'text' property value is 'a' (because 'a' cannot be converted to a number).
  • Boolean values: When trying to compare a Boolean value with non-boolean value, the non-boolean value is converted to a boolean value and then compared. The conversion method assumes that any integer value other than '0' is TRUE, and that '0' alone is FALSE. If the conversion fails to produce a boolean value (for example, if the value is 'abc'), the comparison result will be FALSE (note that for the WaitProperty method this result would instruct QuickTest to keep waiting). If the conversion succeeds, the method compares the two boolean values according to the comparison logic.
  • Other value types: When other value types do not match, they are compared under the assumption that different types are not equal (nor greater than or less than each other).
Syntax

object.CheckProperty (PropertyName, PropertyValue, [TimeOut])

Syntax Details Argument Description object A test object of type . PropertyName Required. A String value.

The name of the property whose value is checked. The available properties are listed in the Identification Properties page under the Properties section for each test object.

PropertyValue Required. A Variant value.

The expected value against which the actual property value should be checked. You can either use a simple value or you can use a comparison object together with the value to perform more complex comparisons.

TimeOut Optional. An ULong object.

The time, in milliseconds, within which QuickTest should check whether the actual value of the property matches the specified expected value. If no value is specified, QuickTest uses the time set in the Object Synchronization Timeout option in the Run tab of the Test Settings dialog box.

Return TypeA Boolean value.  Returns TRUE if the property achieves the value, and FALSE if the timeout is reached before the property achieves the value.

A TRUE return value reports a Passed step to the test results; a FALSE return value reports a Failed step to the test results.

QTP多个Action之间传递参数的方法详解

点击打开链接 脚本的朋友们都会碰到多个Action之间传递参数的问题,想当年我也是研究了好久才成功的,网上虽然有很多文章都在讲这个问题,但是大多都是雷同的抄来抄去不能解决实际问题,也有可能是我太...
  • cometwo
  • cometwo
  • 2015年04月26日 18:45
  • 1698

使用UFT进行接口测试(Web Service、REST)

UFT/QTP11.5整合了对接口测试的支持(API Testing) 今天对UFT接口测试研究了一下,个人觉得还是不错: 一、首先,我们学习一下,What is SOA? In recent yea...
  • xifeijian
  • xifeijian
  • 2013年02月04日 15:22
  • 8610

QTP脚本中使用正则表达式,匹配字符串方法

第一、首先正则表达式使用如下对象。   1、RegExp 这是使用正则表达式匹配模式的主要对象了   属性:   Pattern:一个字符串,用来定义正则表达式。   Igno...
  • wangsy0202
  • wangsy0202
  • 2016年07月06日 16:01
  • 1111

系统学习QTP测试工具的步骤

这篇文章是写给所有想学习或正在学习自动化测试的朋友的,旨在提供一个自动化的学习方向,本文举例将以QTP自带的flight为例,讲解从自动化工具学习到自动框架思想的发展过程:(文章中有些地方会省掉,因为...
  • lykangjia
  • lykangjia
  • 2013年12月11日 10:34
  • 919

《QTP自动化测试最佳实践》前言

自动化测试在国内经过了几年的发展,目前已经取得了一定的进步。测试人员从以前单纯地依赖手工执行黑盒测试,到现在逐渐开展自动化测试项目,采用各类自动化测试工具辅助进行测试,大家逐渐意识到软件质量要得到充分...
  • Testing_is_believing
  • Testing_is_believing
  • 2012年08月22日 11:30
  • 2161

QTP连接Oracle数据库

QuickTest Professional(QTP): 连接Oracle数据库 (2011-01-11 15:39:30) 转载▼ 标签: it qtp oracle...
  • yanglidong
  • yanglidong
  • 2012年03月22日 15:37
  • 1038

什么是UFT(QTP)?

原文地址链接:http://www.learnqtp.com/what-is-qtp/ 注:本人文法有限、定有翻译疏漏之处、恳请包涵、并给予指正。感谢! What is UFT (QTP)? Uni...
  • dietime1943
  • dietime1943
  • 2017年05月08日 20:40
  • 852

QTP操作Oracle数据库函数

在QTP自动化测试过程中,可能会用到对数据库的操,其它的数据库例如Mysql、SqlServer、DB2等类似,只是ConnectionString连接字符串不一样,不同的数据库,连接串略有差别,以下...
  • xifeijian
  • xifeijian
  • 2012年11月21日 20:14
  • 1693

【自动化测试工具】QTP/UFT入门

准备工作: QTP11.5安装教程:http://www.iquicktest.com/qtp-uft-11-5-download.html 注: QuickTest Pro(QTP)11.5后更...
  • sanlengjingvv
  • sanlengjingvv
  • 2014年01月20日 14:34
  • 32450

简述QTP自动化测试框架

一提到框架,很多新入手的朋友们可能会一头雾水。最早的我也是如此,经过一段时间的自动化测试实际使用,我把框架的概念作了一个简化的理解。   实现QTP自动化测试框架实际上要由以下几个部分组成: ...
  • Galina1988
  • Galina1988
  • 2015年03月08日 23:17
  • 496
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:QTP之CheckProperty Method
举报原因:
原因补充:

(最多只允许输入30个字)