首页 > Linux操作系统 > Linux操作系统 > Using Variables

Using Variables

原创 Linux操作系统 作者:ipqiaojj 时间:2009-03-14 09:27:47 0 删除 编辑

Using Variables

You can specify variables to store test objects or simple values in your function library. When using a variable for a test object, you can use the variable instead of the entire object hierarchy in other statements. Using variables in this way makes your statements easier to read and to maintain.

To specify a variable to store an object, use the Set statement, with the following syntax:

Set ObjectVar = ObjectHierarchy

In the example below, the Set statement specifies the variable UserEditBox to store the full Browser > Page > WebEdit object hierarchy for the username edit box. The Set method then enters the value John into the username edit box, using the UserEditBox variable:

Set UserEditBox = Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username")

UserEditBox.Set "John"

Note: Do not use the Set statement to specify a variable containing a simple value (such as a string or a number).

You can also use the Dim statement to declare variables of other types, including strings, integers, and arrays. This statement is not mandatory, but you can use it to improve the structure of your function library. In the following example, the Dim statement is used to declare the actual_value variable, which can then be used in different statements within the current function library:

Dim actual_value

       ' Get the actual property value

       actual_value = obj.GetROProperty(PropertyName) 

来自 “ ITPUB博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

下一篇: Using Parentheses


  • 博文量
  • 访问量