注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

gmd20的个人空间

// 编程和生活

 
 
 

日志

 
 

QTP Extensibility Accelerator 自定义Web Add-in对象添加“识别属性  

2010-06-11 21:05:50|  分类: 程序设计 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |


在界面上添加“属性”,在javascript的方法 get_property_value 中添加代码返回相应的值即可,例如

function get_property_value(property)
{

    if (property == "outertext") { //自己重写基类的outertext属性
        return _elem.outerText;
    }
    else if (property == "rowindex") { //对自己新加的属性的
        return getRowIndex();  

如果希望继承的基类的原有Identification Properties也可以用,就也需要添加上属性,但不需要在get_property_value那里处理。比如继承自WebElement的自定义对象,要原有的outertext属性也可以用时,就需要添加一个名字为outertext的属性给你的新类。可以在界面上添加,不可以控制某些属性的时候,可能需要手工编辑对应的“*TestObjects.xml” 文件吧,那个配置文件指定了你的自定义对象的属性和方法等。

注意: 属性最好返回string的字符串类型,在javascript用var i=3; i.toString()转换一下。我发现返回数字类型的时候在qtp的“描述式编程”(Programmatic Descriptions)方式在代码里面指定对象的话,整型数的属性使用不了。

===============================================

HP QTP 文档

Implementing Support for Identification Properties

In the test object configuration file you defined the identification properties for your test object classes. When QuickTest runs a test it needs to retrieve the values for these properties. QuickTest uses identification property run-time values in different test object methods, such as GetROProperty. Identification property run-time values are also required for different basic capabilities, such as creating checkpoints and outputting values.

To support retrieving the run-time values of identification properties, you need to implement a JavaScript function that accepts a PropertyName parameter and returns the value of any property QuickTest requests. (QuickTest uses only lowercase letters in identification property names. If the identification property name in the test object configuration file contains uppercase letters, they are converted to lowercase.)

This function must return the property value in one of the following formats: String, Integer, Boolean, or array. When returning an array, use the toSafeArray function to convert the array to the format that QuickTest expects. When you provide an identification property value in an array format, QuickTest converts the array to a semicolon-delimited string.

For more information on writing JavaScript functions for Web Add-in Extensibility, see Designing JavaScript Functions for Your Toolkit Support Set.

QuickTest uses the base test object class implementation to retrieve the identification property values when the following conditions are met:

  • The control includes a base element (for more information, see Extending an Existing Test Object Class).
  • The identification property is defined in the test object configuration file with the same name as a base test object class property.
  • You do not provide a function that returns a value for that identification property.

Implement your JavaScript function to return a value for the identification properties defined in the test object configuration file in the following situations:

  • Base test object class implementation for retrieving the value for this identification property value is not available.
  • The base test object class implementation does not meet your needs.

By designing the function that returns identification property values to return a value for the logical_name property, you can control how QuickTest names test objects of this test object class. For more information, see Customizing the Test Object Name.

In the toolkit configuration file, you can specify the JavaScript file in which you implemented the JavaScript function that retrieves property values. You can also specify the name of the function that you implemented for this purpose (in the Control\Run\Properties element). However, if you do not specify a function name, QuickTest calls get_property_value (PropertyName) and this is the function that you must implement. If you do not specify a file name, QuickTest calls the function from the default JavaScript file you specified in the Control\Settings element (at the test object class level) or in the Controls\Settings element (at the toolkit level). For more information, see the Toolkit Configuration Schema Help.

After you create support for retrieving the run-time values of identification properties, you can test that your toolkit support set correctly enables QuickTest to run checkpoints on your Web elements, output property values, display the property values in the Object Spy, and run test steps with the GetROProperty operation. For more information on testing your toolkit support set, see Testing the Toolkit Support Set During Development.

  评论这张
 
阅读(1133)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017