zoukankan      html  css  js  c++  java
  • 在TestPartner中引用IE对象控制浏览器

    The following example demonstrates how to set a reference to the Microsoft Internet Controls type library and use its objects, methods, and properties to manually code a test script that tests Internet Explorer.

    Create a new test script and name it AutomateIE.

    Click Tools>References. The References dialog box appears.

    Select the Microsoft Internet Controls check box. Click OK.

    Note: The Object Browser now contains the library SHDocVw, which lists all of the Microsoft Internet Control type library members. While viewing a test script, press F2 or click View>Object Browser to display the Object Browser.

    In the code after Sub Main(), declare a variable called myie of type InternetExploreras shown below. IntelliSense appears as you type and lists InternetExplorer as an available object.
    Dim myie As New InternetExplorer

    Add the following line of code to start Internet Explorer :

    >myie.Visible = True

    Add the following line of code to browse to your home page :

    myie.GoHome = True

    Insert a procedure that checks the status of the browser and pauses playback if the browser isn't accessible.

    Click Insert>Procedure.

    Type CheckBusy in the Name field.

    For Type, select Sub.

    For Scope, select Private.

    Click OK.

    Type the following code in the procedure:

    If myie.Busy = True Then
        Sleep 3
    Else
    End If

    Add the following line of code to call the CheckBusy procedure and browse to the Micro Focus home page:

        CheckBusy
    myie.Navigate "http://www.cnblogs.com/testware/"

    Add the following line of code to call the CheckBusy procedure and browse to the Micro Focus Products page:

        CheckBusy
    myie.Navigate "http://www.cnblogs.com/testware/archive/2011/04/06/2006783.html"

    Add the following line of code to return to the Micro Focus home page, hide the address bar, refresh the browser, and exit the test script:

        CheckBusy
    myie.GoBack
    CheckBusy
    myie.AddressBar = True
    myie.Refresh
    CheckBusy
    myie.Quit

    Play back the test script. Note that by setting a reference to another application's test library, you are able to automate the application with by manually scripting the entire test script.

    Your completed test script should be as follows:

    Public myie As New InternetExplorer

    Sub Main()

    myie.Visible = True
    myie.GoHome
    CheckBusy
    myie.Navigate "http://www.cnblogs.com/testware/"
    CheckBusy
    myie.Navigate "http://www.cnblogs.com/testware/archive/2011/04/06/2006783.html"
    CheckBusy
    myie.GoBack
    CheckBusy
    myie.AddressBar = False
    myie.Refresh
    CheckBusy
    myie.Quit

    End Sub

    Public Sub checkbusy()

    If myie.Busy = True Then
        Sleep 3
    Else
    End If

    End Sub

  • 相关阅读:
    抚琴弹唱东流水
    借点阳光给你
    日月成双行影单
    一夜飘雪入冬来
    悼念钱学森
    我的青春谁作主
    重游望江楼有感
    雪后暖阳
    满城尽添黄金装
    敢叫岁月不冬天
  • 原文地址:https://www.cnblogs.com/testware/p/2009741.html
Copyright © 2011-2022 走看看