zoukankan      html  css  js  c++  java
  • 016专家视图测试脚本开发_utility对象

     

    utility对象
    (1)这个例子是:Extendtest
    使用Extend对象加载DLL,我们可以使用它来丰富windows api函数,能够编写更为强大和灵活的测试代码

    实例代码:

    '声明FindWindow方法,调用user32.dll中的FindWindowA函数
    Extern.Declare.micHwnd,"FindWindow","user32.dll","FindWindowA",micString,micString

    '声明SetWindowText方法
    Extern.Declare miclog,"SetWindowText","user32.dll","SetWindowTextA",micHwnd,micString

    '获取记事本的窗口的句柄
    hwnd = Extern.FindWindow("Notepad",vbNullString)

    If hwnd = 0 Then
      MsgBox"未能找到记事本窗口"
    End If
    '改变记事本窗口的标题
    res = Extern.SetWindowText(hwnd,"Hello world")

    结果:当记事本打开的时候记事本的标题是”Hello world“,但是有如下的问题:

    (2)SystemUtil对象:调出计算器程序
    如:
    '控制应用程序和进程
    Systemutil.Run"calc"
    (3)reporter对象:可用于发送信息到测试结果文件,这对于测试结果分析比较有用。可以使用Reporter对象的ReportEvent方法来向测试结果写入一个事件
    如:
    Reporter.ReportEvent micDone,"开始学习QTP","学习QTP很快乐"
    Reporter.ReportEvent micFail,"开始学习QTP","学习QTP很痛苦"

    二、参数化中:变量放入data table和随机数。

    Window("Flight Reservation").ActiveX("MaskEdBox").Type "121214"
    Window("Flight Reservation").WinComboBox("Fly From:").Select DataTable("from_Item", dtGlobalSheet)
    Window("Flight Reservation").WinComboBox("Fly To:").Select DataTable("to_Item", dtGlobalSheet)
    Window("Flight Reservation").WinButton("FLIGHT").Click
    Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select RandomNumber(0, 100)
    Window("Flight Reservation").WinEdit("Name:").Set "tom"
    Window("Flight Reservation").WinButton("Insert Order").Click
    Window("Flight Reservation").Move 414,180

    但选择随机数的时候提示下面的错误:

  • 相关阅读:
    poi 导出Excel
    【EasyUI】combotree和combobox模糊查询
    多线程和Socket套接字
    io流
    前端页面的语法 jquery javascript ajax
    spring+mybatis
    Exchanger 原理
    CountDownLatch、CyclicBarrier和 Semaphore
    sleep() 、join()、yield()有什么区别
    创建线程的方式及实现
  • 原文地址:https://www.cnblogs.com/jiangkeji/p/4057146.html
Copyright © 2011-2022 走看看