B/S架构测试常用方法

上一篇 / 下一篇  2011-12-12 15:09:49 / 个人分类:QTP进阶

1.back

description:

Navigates to the previous page in the browser history list.

syntax:

object.Back

Syntax Details:

object:A test object of type Browser.

Example:

Sub Back_Example()
'The following example uses the Back method to return to the previous page in the browser.

SystemUtil.Run "iexplore.exe", "http://www.google.com"
Browser("Google").Page("Google").Sync
Browser("Google").Navigate "http://www.cnn.com"
Browser("Google").Page("CNN.com - Breaking News,").Sync
Wait 10 ' we can read the latest news
Browser("Google").Back
Browser("Google").Page("Google").Sync
Browser("Google").Navigate "http://www.Yahoo.com"
Browser("Google").Page("Yahoo!").Sync
'The ReadMail function reads all new mail from the specific mail box
ReadMail ("John@yahoo.com")

End Sub

2.check

description:

Checks whether the actual value of an item matches the expected value.

 

syntax:

 

object.Check(Verify)

 

syntax details:

 

object:A test object of typeBrowser.

Verify:

Required. A Variant value.

The checkpoint object that contains the expected values to be compared and verified during the test run.

Example:

Sub Check_Example()
'The following example uses the Check method in a checkpoint on a
'Roundtrip Ticket checkbox.

Browser("Mercury Tours").Page("Find Flights").WebCheckBox("roundtrip").Check CheckPoint("Roundtrip Ticket")

End Sub

 

3.checkproperty

 

description:

 

Checks whether the specified object property achieves the specified value within the specified timeout.

 

syntax:

 

object.CheckProperty(PropertyName,PropertyValue, [TimeOut])

syntax details:

object:A test object of typeBrowser.

PropertyName:Required. A String value.

The name of the property whose value is checked. The available properties are listed in the Identification Properties page under the Properties section for each test object.

PropertyValue:Required. A Variant value.

The expected value against which the actual property value should be checked. You can either use a simple value or you can use a comparison object together with the value to perform. more complex comparisons.

TimeOut:Optional. An ULong object.

The time, in milliseconds, within which QuickTest should check whether the actual value of the property matches the specified expected value. If no value is specified, QuickTest uses the time set in the Object Synchronization Timeout option in the Run tab of the Test Settings dialog box.

Example:

Sub CheckProperty_Example()
'The following example uses the CheckProperty method to check whether
'the text "Mercury" is entered in the "Name" edit box.

Browser("Nested Lists").Page("Page").WebEdit("Name").Set "Mercury"
Browser("Nested Lists").Page("Page").WebEdit("Name").CheckProperty "value", "Mercury"

End Sub

4.childobjects

description:Returns the collection of child objects contained within the object.

syntax:

object.ChildObjects([Description])

syntax detail:

 

object:A test object of typeBrowser.

 

Description:Optional. An Object object.

A Properties (collection) object. 
Tip: You can retrieve a Properties collection using theGetTOPropertiesmethod or you can build a Properties collection object using the Description object.  For more information on the Description object, refer to the Utility section of the QuickTest Professional Object Model Reference.

 

Example:

 

Sub ChildObjects_Example()
'The following example uses the ChildObjects method to find all the
'list objects on a Web page, and then to select an item in each list.

Set Desc = Description.Create()
    oDesc("micclass").Value = "WebList"
Set Lists = Browser("Mercury Interactive").Page("Mercury Interactive").ChildObjects(oDesc)
    NumberOfLists = Lists.Count()
For i = 0 To NumberOfLists - 1
    Lists(i).Select i + 1
Next

End Sub

 

5.close

 

description:

 

Closes the browser window (or tab) that this test object represents.

 

syntax:object.Close

 

syntax details:

 

object:A test object of typeBrowser.

 

Example:

 

Sub Close_Example()
'The following example uses the Close method to close the
'Mercury Tours application.

Browser("Mercury Tours").Page("Search Results").Image("reserveFlights").Click 41, 20
Browser("Mercury Tours").Page("Method of Payment").Image("buyFlights").Click 11, 5
Browser("Mercury Tours").Close

End Sub
 

6.CloseALLTabs

description:

Closes all tabs (if any) and closes the browser window.

Syntax:object.CloseAllTabs

Syntax details:

Object: A test object of typeBrowser.

Example:

Sub CloseAllTabs_Example()
'The following example uses the CloseAllTabs method to close all the tabs
'in a Web browser.
Browser("Mercury Tours").Page("Search Results").Image("reserveFlights").Click 41, 20
Browser("Mercury Tours").Page("Method of Payment").Image("buyFlights").Click 11, 5
'Open another tab in the browser
Browser("Mercury Tours").OpenNewTab
'Perform. an operation on the second tab
Browser("Google Browser").Page("Google").WebEdit("q").Set "Hello World"
'Close both tabs
Browser("Mercury Tours").CloseAllTabs
'or you can use the following line as well
'Browser("Google Browser").CloseAllTabs
End Sub

7.forward

Description: Navigates to the next page in the browser history list.

Syntax: object.Forward

Syntax details:

Object: A test object of typeBrowser.

Example:


 

Sub Forward_Example()
'The following example uses the Forward method to navigate to
'the following page after the Back method has been used.

Browser("Mercury Tours").Page("Find Flights").Image("findFlights").Click 103, 13
Browser("Mercury Tours").Back
Browser("Mercury Tours").Page("Find Flights").WebRadioGroup("seatType").Select "Coach"
Browser("Mercury Tours").Forward
Browser("Mercury Tours").Page("Search Results").Check CheckPoint("Search Results")

End Sub

8.FullScreen

Description:Displays the browser in full-screen mode.

Syntax:object.FullScreen

Syntax details:

 

Object: A test object of typeBrowser.

 

Example:

 

Sub FullScreen_Example()
'The following example uses the FullScreen method maximize the
'browser.

Browser("Web Testing").FullScreen

End Sub

 

9.GetROProperty

 

Description:Returns the current value of the test object property from the object in the application.

 

Syntax:

 

object.GetROProperty (Property, [PropertyData])

 

syntax details:

 

object: A test object of typeBrowser.

Property: Required. A String value.

The property to retrieve from the object.

PropertyData: Optional. A Variant value.

Not in use.

 

Example:

 

Sub GetROProperty_Example()
'The following example uses the GetROProperty method to retrieve
'the state of a check box.

Val = Browser("Mercury Tours").Page("Find Flights").WebCheckBox("roundtrip").GetROProperty("Value")
' val contains the ON or OFF state of the check box

End Sub

 

10.GetTOProperties

 

Description:Returns the collection of properties and values used to identify the object.

Syntax: object.GetTOProperties

Syntax details:

 

Object: A test object of typeBrowser.

 

Example:

 

Sub GetTOProperties_Example()
'The following example uses the GetTOProperties method to retrieve
'the list of properties and values used to identify the FirstName
'WebTable.

Set TableDesc = Browser("Mercury Tours").Page("Method of Payment").WebTable("FirstName").GetTOProperties

End Sub

 

11.GetTOProperty

 

Description:Returns the value of the specified property from the test object description.

Syntax: object.GetTOProperty (Property)

Syntax details:

 

Object: A test object of typeBrowser.

Property: Required. A String value.

The property to retrieve from the object description.

 

Example:

 

Sub GetTOProperty_Example()
'The following example uses the GetTOProperty method to retrieve
'the value of the WebTable's HtmlTag property from the Object
'Repository.

TableTag = Browser("Mercury Tours").Page("Method of Payment").WebTable("FirstName").GetTOProperty("HtmlTag")
' TableTag contains "TABLE"

End Sub

 

12.home

 

Description:Navigates to the home page configured in the browser's settings.

 

Syntax: object.Home

 

Syntax details:

 

Object: A test object of typeBrowser.

 

Example:

 

Sub Home_Example()
'The following example uses the Home method to return to the
'browser's default Home page.

Browser("Web Testing").Home

End Sub


TAG:

 

评分:0

我来说两句

Open Toolbar