发布新日志

  • qtp 不能识别webelement的输入框解决方法

    2008-10-22 20:29:58

    Browser("网易电子邮箱 - 极速3.0正式版").Page("网易电子邮箱 - 极速3.0正式版").Frame("HtmlEditor").WebElement("html tag:= BODY").Object.Focus
    Dim wsh
    Set wsh = createobject("wscrīpt.shell")
    wsh.sendkeys "abcdefg"
    Set wsh = nothing

     

    但我目前还不知道具体focus属性是什么

  • qtp 描述性编程 对象

    2008-10-22 20:29:58

    例如,假设我们需要完成以下一个操作:

    Window("Error").WinButton("text:=OK", "index:="1"").Click

    我们可以通过Descrīption对象来实现同样的功能,参加下面的代码:

    Set MyDescrīption = Descrīption.Create()

    MyDescrīption("text").Value = "OK"

    MyDescrīption("index").Value = 1

    Window("Error").WinButton(MyDescrīption).Click

    Set MyDescrīption = Nothing

  • qtp 获取web table

    2008-07-08 16:19:48

    Set Cell = Browser("Welcome: Mercury Tours").Page("Book a Flight: Mercury").WebTable("New York to San Francisco")' 这样 Cell = New York To San Francisco 这个table了。

    Set Functionout = ObjectsByMicClass(Cell, "WebElement")

  • qtp 文件读写

    2008-07-07 14:32:33

    fileobject = fso.Getfile(path)

    TextSream = FileObject.OpenAsTextStream(mode,format)

    TextStream = FSO.CreateText.File(filename, bOverwrite)

    注意三个函数的返回值。

     

    例子一:

    Dim txtapp
    Dim  f

    Set txtapp =  CreateFile("d:/qtp.txt",true)   '返回TextSream.
    WriteToFile txtapp ,"this is the fist line"     '直接把txtapp放到WriteToFile里

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    Function CreateFile(sFile, bOverwrite)

        Set fso = CreateObject("scrīpting.FileSystemObject")

        set CreateFile = fso.CreateTextFile(sFile, bOverwrite)   '返回TextSream.并且注意这个时候不能执行 CreateFile.close.否则后面就不能写入。(因为和后面写入的是同一个 TextStream .)
     

    End Function

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    function  WriteToFile(sFilename, sLine)
     
    Const ForWriting =2
    Set fso = CreateObject("scrīpting.FileSystemObject")

    sFilename.Write sLine

    sFilename.Close

    End function

    ***********************************************************************************

    ************************************************************************************

    例子2

    Dim txtapp

    Set txtapp =  CreateFile("d:/qtp.txt",true)   '返回TextSream.

    WriteToFile "d:/qtp.txt" ,"this is the fist line" '是把路径传给了 WriteToFile.

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    Function CreateFile(sFile, bOverwrite)

        Set fso = CreateObject("scrīpting.FileSystemObject")

        set CreateFile = fso.CreateTextFile(sFile, bOverwrite)   '返回TextSream
      CreateFile.close                                    '注意 一定要关闭。否则下次打开的时候,就不能写入

    End Function

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    function  WriteToFile(sFilename, sLine)
    Dim getf
    Dim f
    Const ForWriting = 2
    Set fso = CreateObject("scrīpting.FileSystemObject")

    set  getf =fso. getfile(sFilename) '返回 file object ,这时进来的是 path

    Set f =getf.OpenAsTextStream( ForWriting,-2) '返回text sream

    f.Write sLine

    f.Close

    End function

     

     

     


     

     

     

     

     


     

  • qtp plus 实例 分析

    2008-07-04 14:13:47

    在 qtp plus中有这么一段代码,

    Function SaveWorkbook(ExcelApp, workbookIdentifier, path) 'As String

      Dim workbook 'As Excel.workbook

      On Error Resume Next

      Set workbook = ExcelApp.Workbooks(workbookIdentifier)

      On Error GoTo 0

      If Not workbook Is Nothing Then

      If path = "" Or path = workbook.FullName Or path = workbook.Name Then

      workbook.Save

    但在运行时workbook = ExcelApp.Workbooks(workbookIdentifier)会提示找不到对象。通过断点调试,发现workbook是空的。

    找了一天都没找到原因,后来无意发现当record and run setting里,web和app都选择 record and run on  any******后运行就通过。

    具体原因未知。 

我的栏目

数据统计

  • 访问量: 5481
  • 日志数: 10
  • 建立时间: 2008-07-04
  • 更新时间: 2009-01-09

RSS订阅

Open Toolbar