发布新日志

  • 【转载】框架经理-FrameworkManager简介

    2009-05-19 16:12:50

    框架经理-FrameworkManager简介

    作者:陈能技

    前言
        FrameworkManager是由Yaron Assa(www.AdvancedQTP.com)开发的一个开源的QTP自动化测试框架,目的是让QTP的脚本编写更为优雅和清晰(for elegant, clean scripting with QTP)。

    一、FrameworkManager简介
        FrameworkManager处理了应用程序的UI层的所有麻烦和细枝末节的琐碎事情,让你编写出更好、更清晰、更简介的测试脚本。FrameworkManager除了提供一个极为简单的接口用于构建和维护脚本之外,还解决了QTP的对象库和描述性编程的问题。
     
        通常我们构建的代码会变得很臃肿,过于复杂而难以维护,例如写了很多的Select-Case或If结构的语句(如果输入域仅能接受Email格式数据,则这样;如果只能接受地址,则那样...)。按照这种方式写的脚本会难以维护,因为一旦被测试的应用程序添加了新的输入域,则需要重复很多代码修改和调整的工作,使用FrameworkManager则能让这些工作成为过去。
     
        FrameworkManager仅仅关注脚本需要的信息,从而保持脚本代码的简单,避免凌乱的代码。决策判断的结构语句被分解成独立的小类,这些小类可以被轻易地维护和更新,而不至于引入大量的BUG。更重要的是,FrameworkManager是环境无关的,能被轻易地扩展用于处理那些尚未被识别的对象和控件。

    二、FrameworkManager的特点
        下面列举FrameworkManager的一些功能特性:
    1.保持脚本简洁明了。处理对象变成了简单的oObject.Input(“New Value”)。
    2.在内部自动处理不同输入类型,例如两个文本输入框,一个仅能输入Email,一个仅能输入数字。
    3.在内部自动处理相互关联的操作,也就是说,把两个或多个对象操作组合成一个逻辑顺序的操作,例如单击一个按钮来验证输入框的数据;输入密码紧跟着验证密码。

    4.在内部自动选择值验证的方式,例如:
    Delegation – 在某个对象中输入一个值,但是在另外一个对象中显示出来。 Regular Expressions – 输入一个值,但是以前缀或后缀显示出来。
    5.在内部自动处理条件输入-你可以很容易地设置一个标记来标识某个对象是不可输入的或不可操作的(untouchable),例如你有两个输入域,通过一个按钮来控制其“enabled”和“disabled”属性。
    6.在内部自动处理随机值-例如从一个combo-box或list-box控件中随机选择其中的一项。
    7.可轻易地为应用程序对象添加个性化的属性,例如标志某些输入域为强制性的(mandatory),把这些输入域与某个查询窗口中的数据域关联,然后在脚本中利用这些数据,快速填充这些强制性输入域的数据。
    8.被测试应用程序的对象都被结构化成一个树状,让你可以在脚本中做复杂的对象搜索和操作,例如在某个TAB页下的所有输入框输入所有数据;从一个WebTable转到其父级的Frame中。
    9.为了更好地组织对象树,可以添加一些虚拟的层次,从而得到一个可读性更强的对象树。
    10.可扩展性强-可以在不修改已有代码的情况下添加新的数据类型产生和输入方法。FrameworkManager可以处理你添加的任何扩展、不可识别的控件和针对被测试应用程序的业务逻辑处理。
    三、获取FrameworkManager
        FrameworkManager目前的最新版本是0.81,可到以下地址下载:
    http://www.advancedqtp.com/knowledge-base/projects/frameworkmanager/frameworkmanager-version-081/ 下载后把文件解压出来,可看到FrameworkManager的文件结构如下所示: \Documentation 帮助文档。 \Libraries FrameworkManager框架的代码,包括对象树类、输入类等。 \Resources 包含对象树的Excel文件。 \Demo App 用于演示FrameworkManager用法的Demo小程序。 \Tests 用于演示FrameworkManager用法的Test。

    四、FrameworkManager框架的组成
    FrameworkManager框架主要由3大部分组成:
    1.对象树文件(ObjectTree)
    这个Excel文件作为可扩展的对象库(Object-Repository),它包含FrameworkManager识别对象所需要的所有数据,以及所有对象的元数据(meta-data),例如强制输入域等。
    2.对象树类(clsTreeLevel)
    这个类包含FrameworkManager的真正机制。在运行时,根据对象树Excel文件生成对象树实例,所以对象操作都是通过树节点进行封装的。
    3.子类(Min、i-classes)
    对于树中的每一个节点(例如clsTreeLevel类中的每一个实例),都可以“插入”(plugged)一个这样的子类(mini-class)。它们控制相关的程序对象如何输入数据、操作,如何产生随机的数据等。

    对象树Excel文件
         可以在\Resources\ObjectTree.xls中找到该Excel文件,如果要让clsTreeLevel.vbs正确地运行起来,请确保把clsTreeLevel.vbs文件中的sExcelFile这个常量的值修改为Excel文件所在的实际路径,对象树类与对象树就是通过这个常量关联起来的。
    打开Excel文件可看到如图1所示的内容
        

        可以看到Excel文件分成两部分,左边部分是具有层次结构关系的对象树,右边部分是对象的相关属性,例如QTPClass、InPutType等。 下面解释一下Excel表中右边部分的各个列名所代表的属性的含义:
    ? Mandatory – True/False:用于标识该输入域是否为强制性的。
    ? Condition-只有当该输入域的条件得到满足时,才输入。在Excel单元格中填写的格式是:FieldName>Expected Value| FieldName>Expected Value(多个条件用“|”隔开),例如VB Demo_Example 2_Field 1_Enable_Flag>False表示在对象数中该节点的值必须为False。对于负条件,则使用:FieldName>%NOT%UnExpectedValue
    ? PreActions – 在输入之前必须完成的操作,填写格式为:FieldName>Value|FieldName>Value(多个前置的操作用“|”隔开),输入空值可用“%EMPTY%”表示。
    ? PostActions-与PreActions类似,用于表示在输入之后必须完成的操作。
    ? DPID-对象的描述性编程字符串,例如:vbname:=Something|visible:=True。如果不想使用描述性编程,而是希望通过自己编写的函数来指向一个QTP对象的话,则可使用“%FunctionName%”来获取,例如下面的GetBrowser函数:
        Function GetBrowser(sRedundentParam)
         If Browser("Something").Exist then
        Set GetBrowser = Browser("Something") 
        Else Set GetBrowser = Nothing End If End Funtion

    QTPClass-指定对象的类型(micclass),例如VBCombobox、Browser等。
    ? InputType-当给对象树的某个节点输入时采用的子类,例如Text、Combo。这里填入的子类名加上前缀“Input”和后缀“Class”就成为脚本中能识别的子类(mini-class),对应IputClasses.vbs中的InputTextClass、InputButtonClass等。
    ? Type-对象树节点的业务逻辑意义,例如Field、Tab、SaveButton等。
    ? RandomValueType-当给对象树的某个节点随机输入时采用的子类,例如Text、Combo等。这里填入的子类名加上前缀“RandomValue”和后缀“Class”,就成为脚本中能识别的子类,对应RandomValueClasses.vbs中的RandomValueTextClass、RandomValueCheckboxClass等。
    ? ValueInObject-对象树节点的输入操作被验证时所需的标识。有时候在一个字段输入一个值后,需要访问另外一个字段或对象,以便检查输入是否成功。
    ? ValidatePattern-用于验证输入操作的正则表达式。用%Value%表示原本的输入值。用“.*%Value%.*”表示实际值中只要包含了原本的值即为成功。

    ? clsTreeLevel类
        clsTreeLevel类用于构建Excel文件中所描述的对象树的实例。实例化的对象树用一个公共变量oRoot来保持,通过oRoot,可以访问到对象树中的任何一个指定的节点,例如:oRoot.GetLeaf(Identifier),这个方法返回对象节点的实例。 对象树的每个节点都有一个GetChildList和GetParentList方法,用于返回当前节点的儿子对象列表或父亲对象列表,通过这两个方法可以实现对象树节点的导航,访问任何需要的节点。 通过oNode.QTPObject.GetROProperty可以获取某个节点对象的属性,

        例如QTPObject.GetROProperty("enabled")返回对象节点的enabled属性。 每个节点对象都有一个Input方法,用于对被测试应用程序中的相应对象做输入操作,例如单击一个按钮、设置日期等。 每个节点对象都有一个Value属性,可以返回对象的当前值。 如果你想对节点对象做额外的非标准的输入操作,则可以在各输入子类(mini-class)中定义个性化的操作,然后通过ExecuteCustom命令来激活它们。

    ? 输入子类(InputClasses)和随机值子类(RandomValueClasses)
    为了保持主类(clsTreeLevel)的代码稳定、清晰和简洁,处理实际对象的操作和输入并没有在主类中实现,而是在单独的子类中处理,每一个子类负责特定类型的对象的任务处理,例如InputTextClass用于处理标准的文本输入框,InputComboboxClass则用于处理标准combo-box输入框。 目前为止,FrameworkManager提供两种类型的子类(mini-class):输入类(Input)和随机值类(RandomValue)。输入类用于处理对象,随机值类用于产生随机值。每个节点对象通过Excel表格中的设置的InputType和RandomValueType来关联相关的子类。

         可以为FrameworkManager扩展新的子类。如果碰到未处理的控件,可以立即编写一个新的子类,在Excel文件中设置相关的类名即可,而不需要更新那些select-case或if结构语句。

    五、FrameworkManager的使用方法
        基于前面对FrameworkManager框架的分析,我们基本上明白了FrameworkManager的整体框架的原理。下面简单介绍一下FrameworkManager的使用方法。

        首先,需要在Test的Resources中添加FrameworkManager框架文件目录中的Libraries下的几个文件,包括clsTreeLevel.vbs、General.vbs、InputClasses.vbs、RandomValueClasses.vbs,如图2所示。
               
           添加了这些库文件后,就可以使用FrameworkManager了。针对被测试应用程序,我们还需要为其建立对象树,这个需要在ObjectTree.xls文件中进行编辑。包括各个对象节点以及对象节点所对应的输入操作等。 有了对象树后,我们就可以通过类似下面的脚本来使用FrameworkManager进行对象的测试: Call oRoot.GetLeaf("VB Demo_Example 1_Field 1").Input("Random") 读者可以先参考FrameworkManager框架所附带的Demo程序来了解FrameworkManager的使用方法。然后再修改ObjectTree.xls文件,替换成自己的测试项目中的对象和所需的输入操作。

       
     

  • [转载]Indexof 的用法

    2008-11-22 14:26:55

    在很多地方看见了这个函数,但是QTP帮助里并找不到这个方法,于是贴出来供大家参考.

    String.IndexOf 方法 (Char, [startIndex], [count])
      报告指定字符在此实例中的第一个匹配项的索引。搜索从指定字符位置开始,并检查指定数量的字符位置。
      参数
      value
      要查找的 Unicode 字符。 对 value 的搜索区分大小写。
      startIndex(Int32)
      可选项,搜索起始位置。不设置则从0开始。
      count(Int32)
      可选项,要检查的字符位置数。
      返回值
      如果找到该字符,则为 value 的索引位置;否则如果未找到,则为 -1。
      IndexOf()
      查找字串中指定字符或字串首次出现的位置,返首索引值,如:
      str1.IndexOf("字"); //查找“字”在str1中的索引值(位置)
      str1.IndexOf("字串");//查找“字串”的第一个字符在str1中的索引值(位置)
      str1.IndexOf("字",start,end);//从str1第start+1个字符起,查找end个字符,查找“字”在字符串STR1中的位置[从第一个字符算起]注意:start+end不能大于str1的长度
      indexof参数为string,在字符串中寻找参数字符串第一次出现的位置并返回该位置。如string s="0123dfdfdf";int i=s.indexof("df");这时i==4。
      如果需要更强大的字符串解析功能应该用Regex类,使用正则表达式对字符串进行匹配。
      [转贴]原信息URL:http://www.jiaonan.net/html/blog/1/23464.htm
      indexof() :在字符串中从前向后定位字符和字符串;所有的返回值都是指在字符串的绝对位置,如为空则为- 1
      string test="asdfjsdfjgkfasdsfsgfhgjgfjgdddd";
      test.indexof('d') =2 //从前向后 定位 d 第一次出现的位置
      test.indexof('d',1) =2 //从前向后 定位 d 从第三个字符串 第一次出现的位置
      test.indexof('d',5,2) =6 //从前向后 定位 d 从第5 位开始查,查2位,即 从第5位到第7位;
      lastindexof() :在字符串中从后向前定位字符和字符串;、
      用法和 indexof() 完全相同。
      下面介绍 IndexOfAny ||lastindexofany
      他们接受字符数组做为变元,其他方法同上,返回数组中任何一个字符最早出现的下标位置
      如下
      char[] bbv={'s','c','b'};
      string abc = "acsdfgdfgchacscdsad";
      Response.Write(abc.IndexOfAny(bbv))=1
      Response.Write(abc.IndexOfAny(bbv, 5))=9
      Response.Write(abc.IndexOfAny(bbv, 5, 3))=9
      lastindexofany 同上。

     

  • [原创]自动点击outlook中安全页面中yes按钮的方法

    2008-11-15 18:54:58

    以前写过一个方法,使用在QTP中OUTLOOK自动发邮件,但是大家在使用的时候经常会发现OUTLOOK会弹出一个安全确认的窗口,以前我们的解决方法是自己写个工具来解决,这次我们用QTP脚本来实现:

    我们可以使用以下的脚本来实现自动处理该页面.

    Set fso = CreateObject("Wscrīpt.Shell")
     
    While fso.AppActivate("Microsoft Outlook") = FALSE
      wscrīpt.sleep 1000
    Wend
     
    fso.SendKeys "a", True
    fso.SendKeys "y", True
     
    wscrīpt.sleep 7000
     
    While fso.AppActivate ("Microsoft Outlook") = FALSE
      wscrīpt.sleep 1000
    Wend
     
    fso.SendKeys "y", True

    当然我们可以放在VBS里引用这方法.
  • [原创]浅谈自动化测试的脚本框架

    2008-11-15 17:48:59

    浅谈自动化测试的脚本框架

    风过无息

    引子

    随着这几年测试的重要性被越来越多的公司认识到,测试行业也如火如荼的发展起来,测试不再是可有可无,谁都可以做,也不再是比开发矮一个台阶的职务了,而象征测试的一些特色的技能也被更多的人关注和重视.其中自动化测试就是一个特殊的领域.随着技术的发展,自动化测试已经不是少数几个大公司专用的测试技术,很多公司都开展了这方领域的学习和尝试,整理这几年在论坛上发贴的关注度不难发现,从前的问题很多是询问工具下载地址,破解方法和入门学习手册,而今不少是在谈论自动化测试的构建,这是因为大家在实践中会遇到了一些瓶颈,经常会发现脚本维护的工作量远远高于手工测试.这样的效率不是大领导们希望看见的,也是自动化测试必须解决的问题,于是很多人开始对脚本的管理和可重用性,可扩展性进行很多坚持不懈的研究.

    介绍

    社会上有一些主流的自动化设计框架的理论和介绍,本文笔者将结合工作使用的silktest QTP,介绍对自动化框架的认识和在项目的实践的体会,很多观点只代表个人意见.

    在此笔者将自动化脚本分5,分别如下:

    测试用例层

    提取层

    应用层

    普通层

    工具层

     

    解释

    以下笔者将介绍这几个层的概念.

    测试用例层

    该层就是我们实现测试用例的脚本.

    在此我把脚本分为两类,一类叫做主脚本,另一类叫做子脚本,从字面上理解,子脚本是实现各个功能点的脚本,当然也会提取出一些共用的方法,我们会放在提取层中,下面会提起.而主脚本就是根据业务流程的需要来控制各个子脚本,来实现脚本间的数据传递.

    题外话,我们会在主脚本中使用数据驱动,来控制脚本的实现各种场景的流程.在此个人感觉silktesttest suites test plan的概念是一个很现成的管理脚本的方法,而在QTP,我们可以建立一个main action来实现这样的功能.

     

    提取层

    本层是一个项目脚本可维护性的关键,我们会把项目共用的常量,通用的方法,函数放在该层.而这些方法和函数往往是这个自动化项目中最难设计的一块,不同的项目可能使用的方法和思路也不一样.项目中很大的一部分工作量会消耗在这里.比如我会把脚本进入的初始化的方法放在这里,该方法将帮我配置我的运行环境,从服务器上拷贝数据,当然也会针对一些已知的或者或未知的异常情况进行处理,来恢复正常的下个脚本的运行.silktest,我们会放在INC文件下,QTP我们可以自己写一些VBS的文件等外部文件来存放和维护.

     

    应用层

    我们的对象库就是放在本层,做自动化的人都清楚对象库的好坏直接决定了该项目自动化的成败,相对于QTP有强大的对象库管理的功能, silktest相对就是一个比较原始和底层的对象管理模式,更像使用描述性编程的QTP,当然两者之间还是有很多差异.在此笔者建议假如是大规模的项目,不妨专人负责对象库的维护和管理,该人需要很高的自动化经验,他的责任不仅仅在项目初期把底层的对象库建立起来,在中期和后期对对象库的维护,更多的是针对项目的特殊情况对工具层提供的方法进行继承和扩展.比如我们可以对close的方法进行扩展,添加自己的LOG日志,甚至可以结合普通层中对于性能的方法进行一些性能数据的采集等.在项目的实践过程中,会有事半功倍的效果的.

     

    普通层

    这层是衡量一个公司自动化水平的标志,这里集合了很多项目的经验,是一个通用的方法的集合,通常的我们会把自己的LOG日志的方法,对数据库的操作等等,当然也有一些通用的函数方法放在这里,比如说上面说到的采集性能数据的方法,捕获异常的方法等等.

     

    工具层

    该层就是工具提供的一些方法,比如click,dbclick

     

    此外无规矩不成方圆,文档,备注的维护也是不可忽视的重点,一般的自动化测试都会持续半年以上,所以制订相应的流程,文档规范化是一个好的项目必备的要求.

     

    结束语:

    本文只是笔者自己的一些经验的分享,希望可以抛砖引玉的引起大家的一起学习进步,毕竟在国内自动化的普及和深度都在初级阶段,更需要我们的一起努力来提高.有时间更希望能拿一些具体的例子来讨论这个话题.

    此外本文的题目也让笔者煞费苦心,因为自动化框架的范围很大,而我只是对其中的一部分进行了一些自己的总结,只是实在想不出什么更好的题目,暂且就这样定吧! 谢谢.

  • [转载]QTP获取本机打印机与网络打印机属性

    2008-10-28 17:18:12

    1. 获取本机所有本地与网络打印机属性:

    strComputer = "."
    Set ōbjWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colInstalledPrinters =  objWMIService.ExecQuery ("Select * from Win32_PrinterDriver")

    PrtNameArray = Array ()
    ReDim PrtNameArray (colInstalledPrinters.Count-1)
    i = 0
    For each objPrinter in colInstalledPrinters
     PrtNameArray(i) = objPrinter.Name
     i = i + 1
    Next

    Reference from Microsoft.com (scrīpt Center)

    strComputer = "."
    Set ōbjWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colInstalledPrinters =  objWMIService.ExecQuery _
        ("Select * from Win32_PrinterDriver")

    For each objPrinter in colInstalledPrinters
        Wscrīpt.Echo "Configuration File: " & objPrinter.ConfigFile
        Wscrīpt.Echo "Data File: " & objPrinter.DataFile
        Wscrīpt.Echo "Descrīption: " & objPrinter.Descrīption
        Wscrīpt.Echo "Driver Path: " & objPrinter.DriverPath
        Wscrīpt.Echo "File Path: " & objPrinter.FilePath
        Wscrīpt.Echo "Help File: " & objPrinter.HelpFile
        Wscrīpt.Echo "INF Name: " & objPrinter.InfName
        Wscrīpt.Echo "Monitor Name: " & objPrinter.MonitorName
        Wscrīpt.Echo "Name: " & objPrinter.Name
        Wscrīpt.Echo "OEM Url: " & objPrinter.OEMUrl
        Wscrīpt.Echo "Supported Platform: " & objPrinter.SupportedPlatform
        Wscrīpt.Echo "Version: " & objPrinter.Version
    Next

    获取网络打印机属性

    Reference from QTP Help (Windows scrīpt Host)

    Set WshNetwork = Wscrīpt.CreateObject("Wscrīpt.Network")
    Set ōDrives = WshNetwork.EnumNetworkDrives
    Set ōPrinters = WshNetwork.EnumPrinterConnections
    Wscrīpt.Echo "Network drive mappings:"
    For i = 0 to oDrives.Count - 1 Step 2
       Wscrīpt.Echo "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1)
    Next
    Wscrīpt.Echo
    Wscrīpt.Echo "Network printer mappings:"
    For i = 0 to oPrinters.Count - 1 Step 2
       Wscrīpt.Echo "Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i+1)
    Next

  • 软件自动化测试框架的发展

    2008-03-09 20:14:12

    基于界面的软件自动化测试框架和工具的发展大致经历了三个阶段(有人也据此将测试工具分为三代):

    1)              简单的录制/回放:由工具录制并记录操作的过程和数据形成脚本,通过回放来重复人工操作的过程。在这种模式下数据和脚本混在一起,几乎一个测试用例对应一个脚本,维护成本很高。而且即使界面的简单变化也需要重新录制,脚本可重复使用的效率低。

    2)              数据驱动(data driven)的自动化测试:从数据文件读取输入数据,通过变量的参数化,将测试数据传入测试脚本,不同的数据文件对应不同的测试用例。在这种模式下数据和脚本分离,脚本的利用率、可维护性大大提高,但受界面变化的影响仍然很大。

    3)              关键字驱动(keyword driven)的自动化测试:关键字驱动测试是数据驱动测试的一种改进类型,它将测试逻辑按照关键字进行分解,形成数据文件,关键字对应封装的业务逻辑。主要关键字包括三类:被操作对象(Item)、操作(Operation)和值(value),用面向对象形式可将其表现为 Item.Operation(Value)。关键字驱动的主要思想是:脚本与数据分离、界面元素名与测试内部对象名分离、测试描述与具体实现细节分离。

     

    相应地,软件测试自动化脚本的类型,从低到高的发展层次是:

    1)  线性脚本:通过录制直接产生的线性执行的脚本。

    2)  结构化的脚本:具有顺序、循环、分支等结构的脚本。

    3)  共享的脚本:可以被多个测试用例使用,被其它脚本调用的脚本。

    4)  数据驱动的脚本:数据和流程控制分离的脚本,通过读入数据文件来驱动流程进行的脚本。

    5)  关键字驱动的脚本:脚本、数据、业务分离,数据和关键字在不同的数据表中,通过关键字来驱动测试业务逻辑。关键字驱动脚本的特点是它看起来更像描述一个测试事例做什么, 而不是如何做。

     

    目前,大多数测试工具处于数据驱动到关键字驱动之间的阶段,有些工具厂商已经提出了声称支持关键字驱动的版本。

     

    从上面可以看到,自动化测试框架和脚本的发展是和软件工程思想的发展一脉相承的。软件开发的模式从面向机器、到面向过程、再到面向对象、面向服务,是一个从底层到高层、从具体到抽象、复用的粒度从细到粗的发展过程。而软件开发中的模块化、层次化、松耦合等思想对自动化测试框架的设计都具有借鉴意义。

  • [资料]HP QuickTest Professional 9.5

    2008-02-01 18:52:16

    New Features in HP QuickTest Pro 9.5
    • Maintenance run mode.
    • Process Guidance (best practices and methodologies manuals)
    • All-in-one QuickTest Installation (All of HP QTP on one DVD)
    • New QuickTest IDE Panes (flow, available keywords and resources panes)
    • Checkpoint and Output Objects in the Object Repository.
    • Test Your PowerBuilder Applications in QuickTest
    • Extend QuickTest Web Support for your Custom Web Objects
    • Accelerate SAP Testing with HP Business Process Testing for SAP Applications
    HP QTP 9.5 now supports new technologies:
    • PowerBuilder 9, 10, 10.5 and 11
    • Oracle Forms 10 and Apps 12
    • StingRay Objective Grid 10, 11
    • PeopleSoft 9.0
    • New Terminal Emulator versions
    • NET 3.5 (beta)
    HP QuickTest Professional 9.5 introduces support for new environments
    • Windows Vista 64 bit
    • Eclipse 3.2, 3.3
    • Record on SWT
    • Firefox 3.0
    • Netscape 9 (nice feature, but too late. AOL discontinued support for Netscape)
  • [转载]Scripting Techniques

    2008-01-09 10:23:32


    Adding Elements to a Dictionary


    Demonstration scrīpt that adds three key-item pairs to a scrīpt Runtime Dictionary. scrīpt must be run on the local computer.
    Set ōbjDictionary = CreateObject("scrīpting.Dictionary")
    objDictionary.Add "Printer 1", "Printing"   
    objDictionary.Add "Printer 2", "Offline"
    objDictionary.Add "Printer 3", "Printing"

    Creating an Instance of Internet Explorer


    Demonstration scrīpt that creates an instance of Internet Explorer, opened to a blank page.
    Set ōbjExplorer = Wscrīpt.CreateObject("InternetExplorer.Application")
    objExplorer.Navigate "about:blank"   
    objExplorer.ToolBar = 0
    objExplorer.StatusBar = 0
    objExplorer.Width=300
    objExplorer.Height = 150 
    objExplorer.Left = 0
    objExplorer.Top = 0
    objExplorer.Visible = 1

    Creating scrīpt Documentation Using scrīpt Comments


    Demonstrates the use of the FileSystemObject as a way to copy comments from a scrīpt to a separate text file. Requires comments to have been marked using '*.
    Const ForReading = 1
    Const ForWriting = 2
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    Set ōbjscrīptFile = objFSO.OpenTextFile("c:\scrīpts\Service_Monitor.vbs", _
        ForReading)
    Set ōbjCommentFile = objFSO.OpenTextFile("c:\scrīpts\Comments.txt", _ 
        ForWriting, TRUE)
    Do While objscrīptFile.AtEndOfStream <> TRUE
        strCurrentLine = objscrīptFile.ReadLine
        intIsComment = Instr(1,strCurrentLine,"'*")
        If intIsComment > 0 Then
            objCommentFile.Write strCurrentLine & VbCrLf
        End If
    Loop
    objscrīptFile.Close
    objCommentFile.Close

    Determining the Number of Items in a Dictionary


    Demonstration scrīpt that counts the number of key-item pairs in a scrīpt Runtime Dictionary. scrīpt must be run on the local computer.
    Set ōbjDictionary = CreateObject("scrīpting.Dictionary")
    objDictionary.Add "Printer 1", "Printing"   
    objDictionary.Add "Printer 2", "Offline"
    objDictionary.Add "Printer 3", "Printing"
    Wscrīpt.Echo objDictionary.Count

    Displaying Real Time Events in a Command Window


    Creates a temporary event consumer that monitors the event log for error events. When an error event occurs, the scrīpt displays the event information in the command window.
    strComputer = "."
    Set ōbjWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate,(Security)}!\\" & _
            strComputer & "\root\cimv2")
    Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
        ("Select * from __InstanceCreationEvent within 5 where TargetInstance isa " _
            & "'Win32_NTLogEvent' and TargetInstance.EventType = '1'")
    Do
        Set ōbjLatestEvent = colMonitoredEvents.NextEvent
            Wscrīpt.Echo "Record No.: " & _
                objLatestEvent.TargetInstance.RecordNumber
            Wscrīpt.Echo "Event ID: " & objLatestEvent.TargetInstance.EventCode
            Wscrīpt.Echo "Time: " & objLatestEvent.TargetInstance.TimeWritten
            Wscrīpt.Echo "Source: " & objLatestEvent.TargetInstance.SourceName
            Wscrīpt.Echo "Category: " & _
                objLatestEvent.TargetInstance.CategoryString
            Wscrīpt.Echo "Event Type: " & objLatestEvent.TargetInstance.Type
            Wscrīpt.Echo "Computer: " & _
                objLatestEvent.TargetInstance.ComputerName
            Wscrīpt.Echo "User: " & objLatestEvent.TargetInstance.User
            Wscrīpt.echo "Text: " & objLatestEvent.TargetInstance.Message
    Loop

    Displaying Tabular Output in a Command Window


    Retrieves service data from a computer, and then outputs that data in tabular format in a command window.
    Set colServices = GetObject("winmgmts:"). _
        ExecQuery("Select * from Win32_Service")
    For Each objService in colServices
        intPadding = 50 - Len(objService.DisplayName)
        intPadding2 = 17 - Len(objService.StartMode)
        strDisplayName = objService.DisplayName & Space(intPadding)
        strStartMode = objService.StartMode & Space(intPadding2)
        Wscrīpt.Echo strDisplayName & strStartMode & objService.State 
    Next

    Masking Command Line Passwords


    Demonstration scrīpt that uses scrīptPW.dll to mask passwords entered at the command line.
    Set ōbjPassword = CreateObject("scrīptPW.Password") 
    Wscrīpt.StdOut.Write "Please enter your password:" 
    strPassword = objPassword.GetPassword() 
    Wscrīpt.Echo
    Wscrīpt.Echo "Your password is: " & strPassword

    Masking Passwords Using Internet Explorer


    Demonstration scrīpt that creates an instance of Internet Explorer, and retrieves a password typed into a password-style text box. Requires a Web page named password.htm with the appropriate text box.
    Set ōbjExplorer = Wscrīpt.CreateObject _
        ("InternetExplorer.Application", "IE_")
    objExplorer.Navigate "file:///c:\scrīpts\password.htm"   
    objExplorer.Visible = 1             
    objExplorer.ToolBar = 0
    objExplorer.StatusBar = 0
    objExplorer.Width=400
    objExplorer.Height = 250 
    objExplorer.Left = 0
    objExplorer.Top = 0
    Do While (objExplorer.Document.Body.All.OKClicked.Value = "")
        Wscrīpt.Sleep 250                 
    Loop 
    strPassword = objExplorer.Document.Body.All.PasswordBox.Value
    objExplorer.Quit
    Wscrīpt.Sleep 250
    Wscrīpt.Echo strPassword

    Removing All Elements from a Dictionary


    Demonstration scrīpt that deletes all the key-item pairs from a scrīpt Runtime Dictionary. scrīpt must be run on the local computer.
    Set ōbjDictionary = CreateObject("scrīpting.Dictionary")
    objDictionary.Add "Printer 1", "Printing"   
    objDictionary.Add "Printer 2", "Offline"
    objDictionary.Add "Printer 3", "Printing"
    colKeys = objDictionary.Keys
    Wscrīpt.Echo "First run: "
    For Each strKey in colKeys
        Wscrīpt.Echo strKey
    Next
    objDictionary.RemoveAll
    colKeys = objDictionary.Keys
    Wscrīpt.Echo VbCrLf & "Second run: "
    For Each strKey in colKeys
        Wscrīpt.Echo strKey
    Next

    Removing Debugging Comments


    Demonstrates the use of the FileSystemObject as a way to remove debugging comments from a scrīpt. Requires comments to have been marked as '* BUG.
    Const ForReading = 1
    Const ForWriting = 2
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    Set ōbjTextFile = objFSO.OpenTextFile("C:\scrīpts\CreateUser.vbs", ForReading)
     
    Do While objTextFile.AtEndOfStream <> true
        strNextLine = objTextFile.Readline
        intCheckForBugComment = Instr(strNextLine, "'* BUG")
        If intCheckForBugComment = 0 Then
            strSavedLines = strSavedLines & strNextLine & VbCrLf
        End If
    Loop
     
    Set ōbjTextFile = objFSO.OpenTextFile _
        ("c:\scrīpts\CreateUser.vbs ", ForWriting)
    objTextFile.Write strSavedLines 
    objTextFile.Close

    Removing One Element from a Dictionary


    Demonstration scrīpt that deletes a specific key-item pair from a scrīpt Runtime Dictionary. scrīpt must be run on the local computer.
    Set ōbjDictionary = CreateObject("scrīpting.Dictionary")
    objDictionary.Add "Printer 1", "Printing"   
    objDictionary.Add "Printer 2", "Offline"
    objDictionary.Add "Printer 3", "Printing"
    colKeys = objDictionary.Keys
    Wscrīpt.Echo "First run: "
     
    For Each strKey in colKeys
        Wscrīpt.Echo strKey
    Next
     
    objDictionary.Remove("Printer 2")
    colKeys = objDictionary.Keys
    Wscrīpt.Echo VbCrLf & "Second run: "
     
    For Each strKey in colKeys
        Wscrīpt.Echo strKey
    Next

    Retrieving Command Line Arguments from an Active Directory Container


    Demonstration scrīpt that retrieves the names of all the computers in an Active Directory container, and then returns service information from each of those computers.
    Set ōbjDictionary = CreateObject("scrīpting.Dictionary")
    i = 0
    Set ōbjOU = GetObject("LDAP://CN=Computers, DC=fabrikam, DC=com")
    objOU.Filter = Array("Computer")
    For Each objComputer in objOU 
        objDictionary.Add i, objComputer.CN
        i = i + 1
    Next
    For Each objItem in objDictionary
        Set colServices = GetObject("winmgmts://" & _
            objDictionary.Item(objItem) _
                & "").ExecQuery("Select * from Win32_Service")
        Wscrīpt.Echo colServices.Count
    Next

    Retrieving Command Line Arguments from a Text File


    Demonstration scrīpt that opens a hypothetical text file consisting of server names, then retrieves service information from each on the servers in the file.
    Const ForReading = 1
    Set ōbjDictionary = CreateObject("scrīpting.Dictionary")
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    Set ōbjTextFile = objFSO.OpenTextFile("c:\scrīpts\servers.txt", ForReading)
    i = 0
    Do Until objTextFile.AtEndOfStream 
        strNextLine = objTextFile.Readline
        objDictionary.Add i, strNextLine
        i = i + 1
    Loop
    For Each objItem in objDictionary
        Set colServices = GetObject("winmgmts://" & _
            objDictionary.Item(objItem) _
                & "").ExecQuery("Select * from Win32_Service")
        Wscrīpt.Echo colServices.Count
    Next

    Retrieving a Web Page


    Retrieves the HTML source for the Web page http://www.microsoft.com. This scrīpt contributed by Maxim Stepin of Microsoft.
    url="http://www.microsoft.com"
    Set ōbjHTTP = CreateObject("MSXML2.XMLHTTP")
    Call objHTTP.Open("GET", url, FALSE)
    objHTTP.Send
    Wscrīpt.Echo(objHTTP.ResponseText)

    Saving Data in XML Format


    Demonstration scrīpt that retrieves service information for a computer, and then saves that data as an XML file.
    Const ForAppending = 2
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    Set ōbjTextFile = objFSO.OpenTextFile _
        ("c:\scrīpts\service_status.xml", ForAppending, True)
    objTextFile.WriteLine ""
    objTextFile.Write ""
    objTextFile.WriteLine ""
    strComputer = "."
    Set colServices = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2"). _
            ExecQuery("Select * from Win32_Service")
    For Each objService in colServices    
        objTextFile.WriteLine ""
        objTextFile.WriteLine ""
        objTextFile.WriteLine objService.DisplayName
        objTextFile.WriteLine ""
        objTextFile.WriteLine ""
        objTextFile.WriteLine objService.State
        objTextFile.WriteLine ""
        objTextFile.WriteLine ""
    Next
    objTextFile.WriteLine ""
    objTextFile.Close

    Sorting WMI Data


    Demonstration scrīpt showing how WMI data can be sorted using a disconnected recordset (by itself, WMI does not allow you to specify a sort order for returned data). In this scrīpt, service information is retrieved using WMI and is stored in a disconnected recordset, a recordset that is not tied to a physical data source. The Sort method is then used to sort the service data by service state rather than by service name.
    Const adVarChar = 200
    Const MaxCharacters = 255
     
    Set DataList = CreateObject("ADOR.Recordset")
    DataList.Fields.Append "ServiceName", adVarChar, MaxCharacters
    DataList.Fields.Append "ServiceState", adVarChar, MaxCharacters
    DataList.Open
     
    strComputer = "."
    Set ōbjWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set ServiceList = objWMIService.ExecQuery _
        ("Select * from Win32_Service")
     
    For Each Service in ServiceList
        DataList.AddNew
        DataList("ServiceName") = Service.Name
        DataList("ServiceState") = Service.State
        DataList.Update
    Next
     
    DataList.Sort = "ServiceState"
    DataList.MoveFirst
     
    Do Until DataList.EOF
        Wscrīpt.Echo DataList.Fields.Item("ServiceName") _
            & vbTab & DataList.Fields.Item("ServiceState")
        DataList.MoveNext
    Loop

    Suppressing Multiple Event Notifications


    Issues an alert if available space on a disk drive falls below 100 megabytes. Will wait one hour before issuing the next alert.
    dtmStartTime = Now
    strComputer = "."
    Set ōbjWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set ōbjDiskDrives = objWMIService.ExecQuery _
        ("Select * from Win32_LogicalDisk")
    For Each objDrive in objDiskDrives
        If objDrive.FreeSpace < 10000000 Then
            Wscrīpt.Echo "Drive is low on disk space."
        End If
    Next
    Do
    Set ōbjDiskDrives = objWMIService.ExecQuery _
        ("Select * from Win32_LogicalDisk")
    For Each objDrive in objDiskDrives
        If objDrive.FreeSpace < 10000000 Then
            intElapsedHours = DateDiff("h", dtmStartTime, Now)
                If intElapsedHours >= 1 Then
                    Wscrīpt.Echo "Drive is low on disk space." 
                dtmStartTime = Now
            End If  
        End If
    Next
    Wscrīpt.Sleep 1000
    Loop

    Tracking scrīpt Progress in a Command Window


    Demonstrates the use of StdOut as a method for indicating the progress being made by a scrīpt.
    Wscrīpt.Echo "Processing information. This might take several minutes."
    strComputer = "."
    Set colServices = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2"). _
        ExecQuery("Select * from Win32_Service")
    For Each objService in colServices
        Wscrīpt.StdOut.Write(".")
    Next
    Wscrīpt.StdOut.WriteLine
    Wscrīpt.Echo "Service information processed."

    Tracking scrīpt Progress Using Internet Explorer


    Demonstrates how to use Internet Explorer as a method for indicating the progress being made by a scrīpt.
    Set ōbjExplorer = Wscrīpt.CreateObject("InternetExplorer.Application")
    objExplorer.Navigate "about:blank"   
    objExplorer.ToolBar = 0
    objExplorer.StatusBar = 0
    objExplorer.Width=400
    objExplorer.Height = 200 
    objExplorer.Left = 0
    objExplorer.Top = 0
    Do While (objExplorer.Busy)
        Wscrīpt.Sleep 200
    Loop    
    objExplorer.Visible = 1             
    objExplorer.Document.Body.InnerHTML = "Retrieving service information. " _
        & "This might take several minutes to complete."
    strComputer = "."
    Set colServices = GetObject("winmgmts: \\" & strComputer & "\root\cimv2"). _
        ExecQuery("Select * from Win32_Service")
    For Each objService in colServices
        Wscrīpt.Sleep 200
    Next
    objExplorer.Document.Body.InnerHTML = "Service information retrieved."
    Wscrīpt.Sleep 3000
    Wscrīpt.Quit

    Using a Text File as a Command Line Argument


    Demonstration scrīpt that allows you to drag a text file (consisting of server names) onto the scrīpt icon in Windows Explorer. The scrīpt then opens the text file, then retrieves service information from each on the servers in the file.
    Set ōbjArgs = Wscrīpt.Arguments
    Const ForReading = 1
    Set ōbjDictionary = CreateObject("scrīpting.Dictionary")
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    Set ōbjTextFile = objFSO.OpenTextFile(objArgs(0), ForReading)
    i = 0
     
    Do While objTextFile.AtEndOfStream <> True
      strNextLine = objTextFile.Readline
      objDictionary.Add i, strNextLine
      i = i + 1
    Loop
     
    For Each objItem in objDictionary
      Set colServices = GetObject("winmgmts://" & objDictionary.Item(objItem) _
          & "").ExecQuery("Select * from Win32_Service")
      Wscrīpt.Echo colServices.Count
    Next

    Verifying the Existence of a Dictionary Key


    Demonstration scrīpt that verifies the existence of a particular key within a scrīpt Runtime Dictionary. scrīpt must be run on the local computer.
    Set ōbjDictionary = CreateObject("scrīpting.Dictionary")
    objDictionary.Add "Printer 1", "Printing"   
    objDictionary.Add "Printer 2", "Offline"
    objDictionary.Add "Printer 3", "Printing"
    If objDictionary.Exists("Printer 4") Then
        Wscrīpt.Echo "Printer 4 is in the Dictionary."
    Else
        Wscrīpt.Echo "Printer 4 is not in the Dictionary."
    End If
  • [转]Scripts to manage Text Files

    2008-01-09 10:20:13

    Checking the Size of a File Before Reading It


    Demonstration scrīpt that uses the FileSystemObject to ensure that a text file is not empty before attempting to read it. scrīpt must be run on the local computer.
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    Set ōbjFile = objFSO.GetFile("C:\Windows\Netlogon.log")
    If objFile.Size > 0 Then
        Set ōbjReadFile = objFSO.OpenTextFile("C:\Windows\Netlogon.log", 1)
        strContents = objReadFile.ReadAll
        Wscrīpt.Echo strContents
        objReadFile.Close
    Else
        Wscrīpt.Echo "The file is empty."
    End If

    Creating and Naming a Text File


    Demonstration scrīpt that uses the FileSystemObject's GetTempName method to generate a file name, and then creates a file by that name.
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    strPath = "C:\FSO"
    strFileName = objFSO.GetTempName
    strFullName = objFSO.BuildPath(strPath, strFileName)
    Set ōbjFile = objFSO.CreateTextFile(strFullName)
    objFile.Close
    objFSO.DeleteFile(strFullName)

    Creating a Text File


    Demonstration scrīpt that creates a new, empty text file. scrīpt must be run on the local computer.
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    Set ōbjFile = objFSO.CreateTextFile("C:\FSO\scrīptLog.txt")
    

    Generating a File Name


    Demonstration scrīpt that uses the FileSystemObject's GetTempName method to generate random file names. scrīpt must be run on the local computer.
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    For i = 1 to 10
        strTempFile = objFSO.GetTempName
        Wscrīpt.Echo strTempFile
    Next

    Reading a Text File Character by Character


    Demonstration scrīpt that uses the FileSystemObject to read a text file character-by-character, and individually echo those characters to the screen. scrīpt must be run on the local computer.
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    Set ōbjFile = objFSO.OpenTextFile("C:\FSO\New Text Document.txt", 1)
    Do Until objFile.AtEndOfStream
        strCharacters = objFile.Read(1)
        Wscrīpt.Echo strCharacters
    Loop

    Reading a Text File into an Array


    Demonstration scrīpt that uses the VBscrīpt Split command to read a line from a commas-separated values file, and then place the individual items in that line into an array.
    Const ForReading = 1
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    Set ōbjTextFile = objFSO.OpenTextFile _
        ("c:\scrīpts\servers and services.txt", ForReading)
    Do Until objTextFile.AtEndOfStream
        strNextLine = objTextFile.Readline
        arrServiceList = Split(strNextLine , ",")
        Wscrīpt.Echo "Server name: " & arrServiceList(0)
        For i = 1 to Ubound(arrServiceList)
            Wscrīpt.Echo "Service: " & arrServiceList(i)
        Next
    Loop

    Reading a Text File from the Bottom Up


    Demonstration scrīpt that uses the FileSystemObject to read a text file, and then to echo the text file in inverse order (that is, beginning with the last line in the text file and ending with the first line).
    Dim arrFileLines()
    i = 0
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    Set ōbjFile = objFSO.OpenTextFile("C:\FSO\scrīptLog.txt", 1)
    Do Until objFile.AtEndOfStream
         Redim Preserve arrFileLines(i)
         arrFileLines(i) = objFile.ReadLine
         i = i + 1
    Loop
    objFile.Close
    For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1
        Wscrīpt.Echo arrFileLines(l)
    Next

    Writing Data to a Text File


    Demonstration scrīpt that retrieves the status for all the services installed on a computer, and then saves the service name and status to a text file.
    Const ForAppending = 8
    Set ōbjFSO = CreateObject("scrīpting.FileSystemObject")
    Set ōbjTextFile = objFSO.OpenTextFile _
        ("c:\scrīpts\service_status.txt", ForAppending, True)
    Set colServices =  GetObject("winmgmts:").ExecQuery _
        ("Select * from Win32_Service")
    For Each objService in colServices    
        objTextFile.WriteLine(objService.DisplayName & vbTab & _
            objService.State)
    Next
    objTextFile.Close
  • New HP Support Site

    2007-12-26 10:32:40

    Quick Reference FAQ Version 2
    To ensure your registration on HP Software Support Online (SSO) is quick and easy as possible, we have created the following FAQ to use when you are creating your new HP Passport account.
    SAID and Passport Questions
    Do I need a HP Passport?
    All customers need to register for a HP Passport account.
    What is an HP passport?
    HP Passport is a "single sign-in" service that enables you to use a single user Sign in and password. This tool allows you to define you user id and password and functions on all HP Passport enabled web sites and services. These tools include, but are not limited to the knowledge base, proactive notification via e-mail subscrīptions, online support. For more information, please go to: http://www.managementsoftware.hp.com/news/passport_faq.html
    How do I get an HP passport?
    Go to: www.hp.com/go/hpsoftwaresupport Click on “Register” at the top of the page.
    What is an SAID?
    Service Agreement Identification Number. This number is included in the customer's "Welcome to Support" letter and must be used to verify support and entitlement. This is the value that must be used to access support. This is the only value that will provide you access to support.
    Where can I get help with my SAID? (I didn’t receive a “Welcome to Support”, I can’t remember what my SAID is, or my contract is showing invalid)
    If you are experiencing difficulty using your Service Agreement Id (SAID) number, please follow the online steps to allow us to research your contract and provide you with a valid SAID at www.hp.com/go/hpsoftware/entitlement/investigation. You will only need a HP Passport login to submit this form.
    How do I associate my SAID and passport? I have multiple SAID numbers; which one do I enter in my HP Passport
    Once you create a HP Passport account, 1. Click on “Edit your profile”, 2. Click on “Edit system handle / service agreement identifiers (SAIDs)” 3. Enter your SAID in the box indicated, 4. Click on “Add SAID to Profile”, and (Repeat steps 2-4 for multiple SAID numbers) then, 5. Click on Finished. You MUST have a SAID associated to your account to be able to create cases on HP SSO or the phone. Note only contracts containing HP Software products can be linked to your HP Passport profile
    I had a number assigned to my account while I was a customer of Mercury’s. Will this number remain the same or will the SAID be a new number?
    Your Mercury Maintenance Packaging Number (MPN) will not be the same number at HP. The SAID will be the number you use to log cases with HP.
    How do I create a case? How do I update my case?
    You can create cases online at HP SSO (PREFERRED METHOD): www.hp.com/go/hpsoftwaresupport/casemanager/submitcase Or by phone: www.hp.com/go/hpsoftwaresupport/contact_list
    Find a telephone number for HP OpenView support in your country at www.hp.com/go/hpsoftwaresupport/contact_list
    How do I call support if I can’t log a case on the web?
    How do I create a case if I don’t know my SAID it’s expired but I thought my company renewed?
    1. The customer should dial the country phone number located at: http://h20230.www2.hp.com/contact_list.jsp 2. The customer should advise the agent that they are working with their HP contract to resolve issues regarding their SAID and ask the agent to open a Trust case. 3. The customer should provide the call receipt agent with the Product name, product number, version and details on the issue, contact information and can provide the expired SAID if they have it.
    Online Service and Tools
    How do I log a case on the web?
    Logging a case online is the most efficient and effective way of detailing your problem and enables faster resolutions. The progress of the call can also be tracked online. Go to: www.hp.com/go/hpsoftwaresupport/problem_reporting Or from within the SSO site, click on Support >Problem Reporting.
    What is the escalation process for Mercury customers?
    Call the local support center and ask to speak with a Duty Manager. For more information please see: www.hp.com/go/hpsoftwaresupport/escalation_process
    How can I view my case online? There is not link in the case to view my Service Request.
    Customers in Americas or APJ region can use: http://support.openview.hp.com/sc/mercury-track-case.jsp Customers in EMEA can use: http://kb-web.mercury.com/kba/Siebelview.asp Please note: the EMEA server is replicated several times a times to this view only database, therefore there may be a time delay in posting an update and seeing it online with this link.
    How do I search the knowledge base for manuals, patches, or white papers?
    HP SSO is anticipating an updated SSO portal to be launched soon. Once this portal is launched customers will be able to view Documentation, Alerts & News Archive, Knowledge Base, Patches and Downloads from HP SSO. Until then, please log in with your HP Passport and then to use the online tools, go here: http://support.openview.hp.com/sc/mercurykb.jsp The ETA for this new portal is early December 2007.
    How can I escalate?
    We have an escalation process to assist you if you are not receiving the support you need. If you have submitted an investigation for your SAID and it’s been more than 2 days or you have an open support cases and are not receiving timely support and need to escalate, please call your local support center and ask to speak to a duty manager.
    Can I see my previous Mercury cases on the HP SSO website?
    Data migration of old cases to HP SSO is complete and included that past 2 years worth of Service Requests.
    Partners
    As a Mercury partner I had access to the website. Do I still have access with HP?
    HP provides access to the website for customers and SVI partners. If you are a consultant, please contact the company you are providing work for and obtain their SAID to use on their behalf.
    Quick Reference Matrix
    To help you navigate HP SSO, we have created a quick reference matrix for commonly accessed sites. Additional sites and information can be found on the main SSO page at http://www.hp.com/go/hpsoftwaresupport.
    Service/Program
    URL
    Descrīption
    Register for online support (obtain HP Passport ID)
    http://www.hp.com/go/hpsoftwaresupport
    Click on “Register” at the top of the page.
    Knowledge Search
    http://www.hp.com/go/hpsoftware/advance-self-solve
    A comprehensive knowledge data base where you can search for Software information needed to manage your business. An HP Passport ID is required to
    access this area of the site. Archived Mercury forums can be found by doing an advanced search and selecting “Discussion forums” as the document type.
    Submit an Electronic Support Case
    http://www.hp.com/go/hpsoftwaresupport/casemanager/submitcase
    Electronic support case submission. An HP Passport ID is required to access this area of the site.
    Discussion Forums
    http://forums1.itrc.hp.com/service/forum...mp;familyId=121
    Forum discussion focused on HP management software and associated system management tools for servers. You are required to obtain a ITRC login for this site.
    Patches
    http://www.hp.com/managementsoftware/patches
    Former Downloads section of Mercury and Peregrine support. An HP Passport ID is required to access this area of the site
    Obtain Updates to HP Software
    http://www.hp.com/go/hpsoftwaresupport/software_updates Training located at: http://www.hp.com/go/hpsoftwaresupport/sum_user_guide
    Software Update Manager (SUM) is the electronic notification and delivery mechanism for Software Update Support customers. You are required to obtain a ITRC login for this site. This includes former electronic updates from Mercury and Peregrine
    Manuals
    http://www.hp.com/go/hpsoftware/manuals
    All product manuals are available online.
    Customer Connection
    http://www.hp.com/go/swcustomerconnection
    Customer Connection is a free program targeted for software technical license customers that provides a dedicated program and interactive communication pipeline for proactive, up-to-date information from HP Software.
    Email Notifications
    http://www.hp.com/managementsoftware/emailReg
    Sign-up for notification to patches or enhancement request updates!
    Support News and Alerts
    http://www.hp.com/managementsoftware/servicenews
    Stay up to date on the latest news from HP Software regarding our products and support!
    Ask a Support Contract Question
    http://www.hp.com/managementsoftware/contract_maint
    Your Maintenance Renewal Sales Representative will be able to assist you with renewing or making changes to your support contract or you can request assistance online.

    Followed this and just could not find the LoadRunner KB.anyone here has any success in locating the link for loadrunner.Just a message saying page cannot be found.Time to bell the support guys.
  • 如何解决返回数据库查询纪录条数的总结

    2007-09-28 09:37:31

    大家在使用recordcount来实现返回纪录数的时候会发现返回值是-1或者1的时候,很奇怪,经过研究总结了以下几种获得纪录条数的方法:


    方法一
    Set   oRs   =   Server.CreateObject("ADODB.RecordSet")   
      oRs.Open   sSql,   oConn,   1,   1   
      来读数据.
    仅检索数据:rs.open   SQL,conn,1   
      更新数据:rs.open   SQL,conn,2,2,1

    方法二   
    用Select   Count(*)   As   RecordCount   From   [table]   
      oRs("RecordCount")来获取   
    方法三
    用Do   While   Not   oRs.Eof   
      RecordCount   =   RecordCount   +   1   
      Loop


    方法一原理如下:
    通常人们使用以下两种方法来执行SQL语句:     
      Set   Rs=Conn.Execute(SqlStr)     
      和     
      Set   Rs=Server.CreateObject(“ADODB.RecordSet“)     
      Rs.Open   SqlStr,Conn,CursorType,LockType     
       
      (RecordSet对象方法请看这里)     
       
       
      由于默认的记录集游标是服务器游标,     
      Rs.CursorLocation   =   adUseServer     
      所以返回Rs.RecordCount=-1,     
      应该把服务器游标改为客户端游标,     
      Rs.CursorLocation   =   adUseClient     
      Rs.Open   SqlStr,Conn,CursorType,LockType     
       
      rs.cursortype     
       
      光标类型   recordcount   属性     
      ---------------------------------------------     
      ForwardOnly   0(默认)   返回-1     
      Keyset   1   正确的记录数     
      Dynamic   2   -1或不正确的记录数,依数据源而定     
      Static   3   正确的记录数
  • [原创]使用QTP对TXT文件进行读取和写入

    2007-08-19 13:44:18

    c:\test.txt

    原来是
    ####
    orcal=true
    ####

    ####
    #MySQL=true
    #####

    改为
    ####
    #orcal=true
    ####

    ####
    MySQL=true
    #####

     

    使用函数:

    Function Replace_str(oldstr,newstr)
    Set fso = CreateObject("scrīpting.FileSystemObject")
    Set MyFilebak = fso.CreateTextFile("c:\testbak.txt", True)
    MyFilebak.close
    Set CreFile = fso.GetFile("c:\test.txt")
    CreFile.Copy ("c:\testbak.txt")
    Set MyFilebak=fso.OpenTextFile("c:\testbak.txt", 1, false)
    Set theFile = fso.OpenTextFile("c:\test.txt", 2, True)
    Do While MyFilebak.AtEndOfStream <> True
          retstring = MyFilebak.ReadLine
              If retstring=oldstr Then
                      theFile.WriteLine newstr

                      else
                                theFile.WriteLine retstring
              End If

       Loop
       MyFilebak.close
    Set DelFile = fso.GetFile("c:\testbak.txt")
    DelFile.Delete
       theFile.Close
       ReadEntireFile = retstring
    End Function

    Call Replace_str("#orcal=true","orcal=true")
    Call Replace_str("MySQL=true","#MySQL=true")

     

     

     

  • [原创]随机选取weblist的方法

    2007-08-19 13:41:24

    Function Select_weblist(obj)
       Dim item_count
       item_count=obj.GetROProperty ("items count")
       If  item_count > 0 Then
              Randomize
      Get_Ran=RandomNumber (1,item_count-1)
      obj.Select "#"&Get_Ran
       End If
    End Function

    把对象传进去,就可以自动选取weblist中的值,在实际操作中特别是针对动态的weblist,而且对流程没有影响的的weblist效果不错,拿出来和大家分享.

     

     

  • [原创]ByVal和ByRef的使用介绍

    2007-07-19 18:41:43

    msgv=200
    msgf=300
    aa=100
    Function popmsg(byval msgv,byref msgf)
      msgv=aa
        msgf=aa
    End Function

    Call popmsg(msgv,msgf)
    msgbox msgv
    msgbox msgf

    以上例子大家可以看到ByVal的值没有变化,而ByRef是可以改变值的.现实中灵活运用,会有很好的效果的.
  • [原创]RegisterUserFunc 的使用介绍

    2007-07-18 18:41:39

    Function MySet (obj, x)
    dim y
    y = obj.GetROProperty("value")
    Reporter.ReportEvent micDone, "previous value", y
    MySet=obj.Set(x)
    End Function
    RegisterUserFunc "WebEdit", "Set", "MySet"
    Browser("51Testing软件测试论坛 测试 | 软件测试").Page("51Testing软件测试论坛 测试 | 软件测试").WebEdit("username").Set "test"
    UnRegisterUserFunc "WebEdit", "Set"

    大家可以看到MySet的方法其实是重载了QTP的set的方法,它还取了录制时候的value的值并输出到result中,大家可以看到结果的(见附件).
    由此大家可以修改或者增加QTP的一些方法来灵活的应用.

  • [转载]从Excel往Access导入数据

    2007-07-16 13:50:35

    Sub ADOFromExcelToAccess()
    ' exports data from the active worksheet to a table in an Access database
    ' this procedure must be edited before use
    Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long
    ' connect to the Access database
    Set cn = New ADODB.Connection
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
    "Data Source=C:\FolderName\DataBaseName.mdb;"
    ' open a recordset
    Set rs = New ADODB.Recordset
    rs.Open "TableName", cn, adOpenKeyset, adLockOptimistic, adCmdTable
    ' all records in a table
    r = 3 ' the start row in the worksheet
    Do While Len(Range("A" & r).Formula) > 0
    ' repeat until first empty cell in column A
    With rs
    .AddNew ' create a new record
    ' add values to each field in the record
    .Fields("FieldName1") = Range("A" & r).Value
    .Fields("FieldName2") = Range("B" & r).Value
    .Fields("FieldNameN") = Range("C" & r).Value
    ' add more fields if necessary...
    .Update ' stores the new record
    End With
    r = r + 1 ' next row
    Loop
    rs.Close
    Set rs = Nothing
    cn.Close
    Set cn = Nothing
    End Sub

     

    当然当面的方法也可以改到任何数据库,需要大家自己去试验.

  • [资料]在QTP中关掉进程

    2007-07-03 20:33:54

    这边举例关Outlook

    If Window("Microsoft Outlook").Exist Then
    hwnd = Window("Microsoft Outlook").GetROProperty("hwnd")
    End If

    If SystemUtil.CloseProcessByHwnd(hwnd) Then
    LogWraper "WARNING - ", "Killed Outlook Processes and all its child window by logic hwnd from AO_O2K3_Configscrīpt scrīpt", "STATUS"
    End If

  • [原创]Reporter.ReportEvent的新用法

    2007-07-03 13:26:05

    你试过来自己的Reporter.ReportEvent显示更特殊一些吗?试试下面的操作.

    transNumber = 12345
    Reporter.ReportEvent micPass, "TransactionNumber", "<DIV style='font-size: 7pt; color: white'>&amp;</DIV>"&"<B> <FONT COLOR=#000000>"&transNumber&"</FONT></B>"


    Reporter.ReportEvent micPass, "TransactionNumber", "<DIV style='font-size: 7pt; color: white'>&amp;</DIV>"&"<B> <FONT COLOR=red>"&transNumber&"</FONT></B>"

     

  • [原创]在QTP中判断是否是字符串的方法

    2007-06-29 14:00:15

    判断是否是字符串的方法

    Function checkString (myString)
    checkString = True
    Dim myChr
    For myChr = 48 to 57
    If InStr(myString,Chr(myChr)) > 0 Then
    checkString = False
    Exit Function
    End If
    Next
    End Function

    If checkString("MyString") Then
    MsgBox "OK"
    Else
    MsgBox "False"
    End If

  • [原创]在QTP中把weblist抓图下来

    2007-06-29 10:23:05

    把weblist抓图下来
    Setting.WebPackage("ReplayType") = 2 'Default is 1
    Browser(".").Page(".").WebList(".").Click
    Desktop.CaptureBitmap "C:\Test.bmp",True
    Setting.WebPackage("ReplayType") = 1

     

    相关ReplayType用法,有兴趣可以查阅帮助.

431/3123>
Open Toolbar