首页 > Linux操作系统 > Linux操作系统 > Entering Programmatic Descriptions Directly into Statements

Entering Programmatic Descriptions Directly into Statements

原创 Linux操作系统 作者:ipqiaojj 时间:2009-03-14 10:02:58 0 删除 编辑

Entering Programmatic Descriptions Directly into Statements

You can describe an object directly in a statement by specifying property:=value pairs describing the object instead of specifying an object's name.

The general syntax is:

TestObject("PropertyName1:=PropertyValue1", "..." , "PropertyNameX:=PropertyValueX")

TestObject. The test object class.

PropertyName:=PropertyValue. The test object property and its value. Each property:=value pair should be separated by commas and quotation marks.

Note that you can enter a variable name as the property value if you want to find an object based on property values you retrieve during a run session. For example:

MyVar="some text string"

Browser("Hello").Page("Hello").Webtable("table").Webedit("name:=" & MyVar)

Note: QuickTest evaluates all property values in programmatic descriptions as regular expressions. Therefore, if you want to enter a value that contains a special regular expression character (such as *, ?, or +), use the \ (backslash) character to instruct QuickTest to treat the special characters as literal characters.

The statement below specifies a WebEdit test object in the Mercury Tours page with the Name author and an index of 3. During the run session, QuickTest finds the WebEdit object with matching property values and enters the text Mark Twain.

Browser("Mercury Tours").Page("Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Mark Twain"

Notes: When using programmatic descriptions from a specific point within a test object hierarchy, you must continue to use programmatic descriptions from that point onward within the same statement. If you specify a test object by its object repository name after other objects in the hierarchy have been specified using programmatic descriptions, QuickTest cannot identify the object.

For example, you can use the following statement since it uses programmatic descriptions throughout the entire test object hierarchy:

Browser("Title:=Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Mark Twain"

You can also use the statement below, since it uses programmatic descriptions from a certain point in the description (starting from the Page object description):

Browser("Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Mark Twain"

However, you cannot use the following statement, since it uses programmatic descriptions for the Browser and Page objects but then attempts to use an object repository name for the WebEdit test object:

Browser("Title:=Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Author").Set "Mark Twain"

QuickTest tries to locate the WebEdit object based on its name, but cannot locate it in the repository because the parent objects were specified using programmatic descriptions.

For more information on working with test objects, see Working with Objects.

If you want to use the same programmatic description several times in a function library, you may want to assign the object you create to a variable.

For example, instead of entering:

Window("Text:=Myfile.txt - Notepad").Move 50, 50

Window("Text:=Myfile.txt - Notepad").WinEdit("AttachedText:=Find what:").Set "hello"

Window("Text:=Myfile.txt - Notepad").WinButton("Caption:=Find next").Click

You can enter:

Set MyWin = Window("Text:=Myfile.txt - Notepad")

MyWin.Move 50, 50

MyWin.WinEdit("AttachedText:=Find what:").Set "hello"

MyWin.WinButton("Caption:=Find next").Click 

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

请登录后发表评论 登录


  • 博文量
  • 访问量