zoukankan      html  css  js  c++  java
  • QTP学习笔记之—VBS

    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 

     

     

  • 相关阅读:
    什么是BFC?
    获取JavaScript对象的键值对两种方法的不同之处
    浏览器什么时候会引起reflow,应该怎样避免reflow的开销呢?
    用js实现跳转页面的方法
    停止animate动画和判断是否处于动画状态
    解决slideDown(),slideUp()鼠标来回进入的问题
    IE7浏览器绝对定位被下边元素遮挡问题解决办法
    前端开发面试要点及对策
    inline-block元素之间空白间距的解决办法
    web前端开发和移动前端开发的本质区别在哪里?
  • 原文地址:https://www.cnblogs.com/zelmeli/p/qtp_vbs.html
Copyright © 2011-2022 走看看