几种常见对象无法识别或识别错误的原因

上一篇 / 下一篇  2012-09-11 16:44:16 / 个人分类:QTP

1)设置虚拟对象
先来知悉虚拟对象的方位 Tools-->Virtual object

You can define these objects as virtual objects and map them to standard classes, such as a button or a check box. QuickTest emulates the user's action on the virtual object during the run session. In the test results, the virtual object is displayed as though it is a standard class object. 

You define a virtual object using the Virtual Object Wizard. The wizard prompts you to select the standard object class to which you want to map the virtual object. You then mark the boundaries of the virtual object using a crosshairs pointer. Next, you select a test object as the parent of the virtual object. Finally, you specify a name and a collection for the virtual object. A virtual objectcollectionis a group of virtual objects that is stored in the Virtual Object Manager under a descriptive name.

QuickTest identifies a virtual object according to its boundaries. Marking an object's boundaries specifies its size and position on a Web page or application window. When you assign a test object as the parent of your virtual object, you specify that the coordinates of the virtual object boundaries are relative to that parent object. When you record a test or component, QuickTest recognizes the virtual object within the parent object and adds it as a test object in the object repository so that QuickTest can identify the object during the run session.

map a virtual object to a standard object class, specify the boundaries and the parent of the virtual object, and assign it a name. You can also group your virtual objects logically by assigning them to collections. 

In theIdentify object usingbox, select how you want QuickTest to identify and map the virtual object.

    • If you want QuickTest to identify all occurrences of the virtual object, selectparent only. QuickTest identifies the virtual object using its direct parent only, regardless of the entire parent hierarchy. For example, if the virtual object was defined usingBrowser("A").Page("B").Image("C"), QuickTest will recognize the virtual object even if the hierarchy changes toBrowser("X").Page("Y").Image("C").
    • If you want QuickTest to identify the virtual object in one occurrence only, selectentire parent hierarchy. QuickTest identifies the virtual object only if it has the exact parent hierarchy. For example, if the virtual object was defined usingBrowser("A").Page("B").Image("C"), QuickTest will not recognize it if the hierarchy changes toBrowser("X").Page("B").Image("C").
    • ClickNext.  

  



2)使用相对坐标然后配合WSH去定位对象

3)使用DOM组件接口应用技术。

  DOM的全称是Document Object Model。这种办法只可用于Web项目。举个例子,淘宝网的密码输入框用正常的Set方法是无法操作的,此时就可以调用DOMGetElementById方法,然后进行密码输入的操作。DOM也会在后面的章节中详细介绍,这里不多做阐述

 2.对象可以被QTP识别,但是加载的插件不正确

  发生这种情况总体来说还是幸运的,因为毕竟这也许只是一个误操作,只需要重新加载相对应的正确插件,QTP就可以为你服务了。

3.同一个界面中存在两个或两个以上的属性相同的对象

  有这么一种情况,同一个页面中存在多个属性相同的对象,这种时候QTP会报错并在报错信息中提示我们。像遇到这种问题时,最直接的解决办法就是为每一个对象做一个唯一标识符,最常见的就是设置Index


4.实际运行时的对象发生了改变导致与对象库不匹配

  在自动化测试过程中,很多对象都是动态的,在运行时,属性是一直在发生变化的,比如句柄。碰到类似的问题,解决思路就是先动态获取运行时的值,然后将这个值动态添加到对象库对象中,这样就可以轻松解决该问题了。


TAG: QTP

 

评分:0

我来说两句

日历

« 2024-04-18  
 123456
78910111213
14151617181920
21222324252627
282930    

我的存档

数据统计

  • 访问量: 12048
  • 日志数: 13
  • 建立时间: 2012-09-11
  • 更新时间: 2012-09-26

RSS订阅

Open Toolbar