发布新日志

  • QTP与WinRunner区别

    haiyugg 发布于 2007-07-16 09:44:01

        QTP,全称为Quick Test Professional,它与WinRunner同为MI公司开发的功能强大的功能测试工具。从时间上来看,WinRunner在1995年便已经推出,远早于QTP,而QTP直到2002年才正式推出。从MI公司提供的一些官方资料来看,虽然他们宣称暂时不准备淘汰WinRunner,但他们的宣传资料上又明确表示,QTP已经具备了WinRunner中几乎所有的特性,同时具备了一些独有的特性,并且总体来说,使用更简单、更易扩展和维护,推荐新用户使用QTP,并建议已使用WinRunner的老客户逐渐实现转换。由此看来,MI公司实际上已经有使用QTP逐步取代WinRunner的计划。更重要的是,QTP对J2EE,.NET架构的应用程序支持得比WinRunner要好(从我实际的试用过程中,也感到确实是如此),因此我认为,从我们公司的实际情况出发,针对产品综合部今后将逐步开展自动化测试的计划,QTP应该是一个比较好的选择。
        不论是WinnRunner还是QTP,它们都是功能十分强大的测试工具,加上目前国内关于测试工具的培训和文档资料,实在是少之又少,因此要完全了解和掌握它们,绝不是一朝一夕的事情。在这里我只能就目前对它们的理解程度粗略地介绍一下二者的两点主要不同之处。
        1、使用的脚本语言不同。WinRunner使用的是TSL语言,这是MI公司独有的语言,有特殊性,因此在学习上会有一定难度,不过好在它与C 语言比较类似,如果测试人员有一定的C语言编程基础,会相对容易一些。而QTP使用的则是微软的VBscrīpt语言,比较通用,而且也相对简单易学。从语言上的比较上来看,我个人觉得在编程能力上,WinRunner更胜一筹,因为它拥有相当丰富的C语言函数库,而相对而言,QTP则更大众化,它面向的是没有太多技术背景和编程经验的测试人员。
        2、QTP8.0具有的一大特性:关键字驱动测试(keyword-driven testing)。它的具体操作方法我将有另外的文档详细说明,这里只是简单介绍一下。通过“关键字驱动测试”,测试人员不需要“录制”测试脚本,而可以改成“设计”测试脚本。即:先将应用程序的GUI对象添加到QTP的对象仓库(Object Repository)中,然后针对每一个需要操作到的对象设计每个测试步骤。我个人感觉,这的确是一个很酷的特性,它使我们可以不必实际去操作应用程序,就可以编写出测试脚本,这样做既节省了时间,而且还有一个更大的好处就是可以在应用程序还没有设计完成,或者由于出错无法正常执行的时候仍然可以编写我们的测试脚本。应用程序只需要有使用界面(UI),而不必实际运行,测试人员就可以开始建立测试脚本,为我们实施自动化测试赢得更充足的时间。而在 WinRunner中,虽然也可以采用先学习对象,然后编写代码的方式来完成测试脚本,但这样做要求测试人员对TSL语言比较熟悉才做得到,远不如QTP 来得简单。在实际的操作中我还发现,有些时候采用录制的方法无法捕获对应用程序的操作,此时改用关键字驱动测试却可以收到不错的效果。
        3、相对WinRunner,QTP还具有很多优点,例如“数据表整合”,“Active Screen”,“point and click”,更容易参数化等等

    ================================================

    很多初入行的朋友使用测试工具进行功能测试的时候,总是会遇到QTP和WinRunner的选择问题,为什么同样一家公司会出两个功能类似的工具哪? 下面是一篇关于这两个工具的对比介绍,其实从我自己的经验来看,WinRunner虽然推出较早,但是因为一些功能的缺陷,导致后期很难推广,而Quick Test Professinal(QTP)虽然没有师兄WinRunner出道早,然后内功深厚,所以很受欢迎,而且Mercury公司以后的主要发展策略是QTP,虽然文章中说并没有计划Phase out WR,但是已经不再出新版本了. 针对这两个工具的3年左右的使用经验,我的感受是WR比QTP的逊色的地方主要是几点:

    1. WR的对象管理不如QTP那么有效

    2. WR的语言主要是基于类C的TSL,是Mercury发明的语言,明显不如基于VBscrīpt的QTP强

    3. WR的稳定性不行,而且无意人为的干扰可能导致回放的失败

    4. WR对Java的支持也不如QTP那么强

    WinRunner vs. QuickTest Pro

    Quick Comparison


     



    Overview

    Today Mercury has two functional testing tools – WinRunner (WR) and QuickTest Professional (QTP). WinRunner has been around since about 1995 while QuickTest Pro has been available since about 2002. We have lots of companies asking us “What’s the difference between WinRunner and QuickTest Pro?” and “If they are both functional testing tools from the same company, then which one of the tools should we use?” This document was developed as a short simple reference in helping to understand the basics about the tools in order to answer these two questions.

    Mercury’s position on the two tools is this:

    The strategic direction for Mercury and its customers for Functional Testing is product integration. The new releases of QTP and WR improve already existing integration where customers can leverage complete WinRunner assets (scrīpts/functions) from QuickTest Pro without any modification to these assets.

    QuickTest Pro 8 has recently been released and WinRunner version 8.0 is planned for November 2004. There are no plans to phase out WinRunner.

    QuickTest Pro remains Mercury’s prime product for best customer satisfaction and experience. For customers who need both products, Mercury continues to offer Mercury Functional Testing as a combined package of both product offerings. The Business Process Testing system will be extended to incorporate components designed in WinRunner for the WinRunner 8.0 release in November.



    WinRunner Compared to QuickTest Pro

    Environment Coverage Comparison:

    Common environments shared by both WinRunner and QuickTest Pro:

    Web-Related Environments

    IE, Netscape, AOL

    JDK, Java Foundation Classes, AWT

    Symantec Visual Café

    ActiveX Controls

    ERP/CRM

    Oracle: Jinitiator, 11i, NCA

    Custom Client Server

    Windows

    C++/C

    Visual Basic

    Operating Systems

    Windows 98, 2000, NT, ME, XP

    Legacy

    3270, 5250 Emulators

    VT100

    WinRunner Only Environments:

    Custom Client/Server

    PowerBuilder

    Forte

    Delphi

    Centura

    Stingray

    SmallTalk

    ERP/CRM

    Baan

    PeopleSoft Windows

    Siebel 5, 6 GUI Clients

    Oracle GUI Forms

    QuickTest Pro Only Environments:

    ERP/CRM

    SAP

    Siebel 7.x

    PeopleSoft 8.x

    .Net

    WinForms

    WebForms

    .Net controls

    Web Services

    XML, HTTP

    WSDL, SOAP

    J2EE, .Net

    Multimedia

    RealAudio/Video

    Flash

    Feature Comparison:

    Common features found in both WinRunner and QuickTest Pro:

    Record/Replay

    ODBC & Excel Connectivity

    Code Editor & Debugger

    Recovery Manager

    Shared Object Repository

    Rapid Object Import

    Numerous Checkpoints

    Analog

    scrīpt & Function Libraries

    WinRunner Only Environments:

    Function Generator

    Database Integration

    Run Wizard

    TSL

    MDI

    QuickTest Pro Only Environments:

    ActiveScreen

    TestGuard

    Tree View

    scrīptFusion

    Data Table

    VBscrīpt

    Function Generator*

    (coming in v7.0)

    Run Wizard*

    (coming in v7.0)



    What We Recommend

    QuickTest Pro is our functional testing tool of choice!

    Most customers are in either of two situations:

    Existing WinRunner customers asking “Should we switch to QuickTest Pro?”

    New customers asking “Which should we get, WinRunner or QuickTest Pro?”

    We have been implementing Mercury’s products since 1992 and have senior level expertise in WinRunner. We have been implementing WinRunner since the very first version of it. So like many existing WinRunner customers we have a huge knowledge investment in WinRunner ourselves. However we have worked on the Mercury development team on the QuickTest Pro 6.0 and 6.5 releases, and have solid real-world experience in implementing QuickTest Pro since the 6.0 release. We have found it to be a great tool to use and recommend it to all customers! Overall, we recommend using QuickTest Pro unless for some reason you have to use WinRunner due to an unsupported environment not existing in QuickTest Pro.

    Overall, QuickTest Pro is easier to use and implement for both technical and non-technical testers in comparison to WinRunner. QTP offers many features that are found in WinRunner, but are easier to use. QTP also offers many features not found in WinRunner that make test scrīpt creation, enhancement and maintenance easier.

    Let’s quickly discuss some key issues:

    The WinRunner interface forces the user to look directly at TSL code. TSL is the WinRunner programming language developed by Mercury. It is based on the “C” programming language and therefore looks very similar. For testers who do not have a technical background, they are not always comfortable with having to always look at code. However QuickTest Pro offers a “Tree View” which is an icon-based view of the scrīpt. This is very easy to get used to and non-technical people adapt to it quicker and feel more comfortable working with it. For the technical user, they can always switch over to the “Expert View” in QuickTest and look directly at code, and program away using VBscrīpt.

     

    WinRunner uses TSL which is a proprietary language of Mercury. These types of languages can be very restrictive and you are limited on available resources. QuickTest Pro use the Microsoft programming language VBscrīpt which is very powerful, has lots of capabilities and there are lots of resources available.

     

    We feel that there are many more “point and click” features in QuickTest Pro than WinRunner. This makes its use easier.

    All the same features found in WinRunner are found in QuickTest Pro plus more.

    Data Table integration is much easier and simpler with QuickTest Pro.

    Data Driven Testing is easier with more options in QuickTest Pro.

    scrīpt enhancements are typically easier with QuickTest Pro because it has the Active Screen where the windows and objects in your application are captured for later use. Using a “point and click” capability you can easily interface with objects, their definitions and create checkpoints after having recorded a scrīpt – without having to navigate back to that location in your application like you have to with WinRunner. This greatly speeds up scrīpt development.

    QuickTest Pro currently has built in integration with WinRunner in order to be able to call existing scrīpts, which is great for customers who already have a large test scrīpt investment with WinRunner. Likewise WinRunner 8.0 is to have the ability to also call QuickTest Pro scrīpts. This eases the transition from WinRunner to QuickTest Pro for existing customers.

    Parameterization is much easier in QuickTest Pro and basically anything in QuickTest Pro can be parameterized (statements, checkpoints and the Object Repository).

    Capturing various output values is easier and simpler with QuickTest Pro. Using this capability with parameterization enables you to easily develop scrīpts that can do more in regards to testing.

    We have been implementing QuickTest Pro in real-world environments and have found it much easier to use, advance features are easier to implement and the scrīpt development is quicker. We really enjoy using QuickTest Pro and highly recommend it as the functional testing tool to use.

    QuickTest Pro is our functional testing tool of choice!



    WinRunner

    Summary:

    This product is a mature tool that has been around since approximately 1995. It interfaces with most of the leading development toolkits using the WindowsAPI and toolkit DLLs to interface with the “Application Under Test”.

    WinRunner offers a recording feature that will watch the individual tester and generate a test scrīpt to simulate the same actions just performed. The scrīpt is displayed as a program which can be enhanced with checkpoints, logic and special coding/programming.

    WinRunner also has integration with Excel spreadsheets for data driven testing and the ability to write data out in Excel format or in simple text files.

    Here is the descrīption from the Mercury “Features and Benefits” section of the WinRunner web page:

    Significantly increase power and flexibility of tests without any programming: The Function Generator presents a quick and error-free way to design tests and enhance scrīpts without any programming knowledge. Testers can simply point at a GUI object, and WinRunner will examine it, determine

  • SQL学习

    lisa.chen 发布于 2007-08-27 22:58:04Top 1 Digest 1

    以下是从网上搜索来的知识,我们51testing网站上就有。我觉得对于像我一样不怎么懂行的人来讲,还是很有用的,于是也挂在自己的blog上,以加强记忆,希望斑竹不要骂我浪费空间哦。

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

    SQL语句先前写的时候,很容易把一些特殊的用法忘记,我特此整理了一下SQL语句操作。


    一、基础
    1
    、说明:创建数据库
    CREATE DATABASE database-name

    2
    、说明:删除数据库
    drop database dbname
    3
    、说明:备份sql server
    ---
    创建 备份数据的
    device
    USE master
    EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
    ---
    开始 备份

    BACKUP DATABASE pubs TO testBack
    4
    、说明:创建新表
    create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
    根据已有的表创建新表:
    A
    create table tab_new like tab_old (使用旧表创建新表
    )
    B
    create table tab_new as select col1,col2... from tab_old definition only
    5
    、说明:删除新表

    drop table tabname
    6
    、说明:增加一个列
    Alter table tabname add column col type
    注:列增加后将不能删除。DB2中列加上后数据类型也不能改变,唯一能改变的是增加varchar类型的长度。
    7
    、说明:添加主键: Alter table tabname add primary key(col)
    说明:删除主键:
    Alter table tabname drop primary key(col)
    8
    、说明:创建索引:
    create [unique] index idxname on tabname(col....)
    删除索引:
    drop index idxname
    注:索引是不可更改的,想更改必须删除重新建。

    9
    、说明:创建视图:create view viewname as select statement
    删除视图:
    drop view viewname
    10
    、说明:几个简单的基本的sql语句

    选择:select * from table1 where 范围
    插入:insert into table1(field1,field2) values(value1,value2)
    删除:delete from table1 where 范围

    更新:update table1 set field1=value1 where 范围
    查找:select * from table1 where field1 like '%value1%' ---like的语法很精妙,查资料!
    排序:
    select * from table1 order by field1,field2 [desc]
    总数:
    select count as totalcount from table1
    求和:
    select sum(field1) as sumvalue from table1
    平均:
    select avg(field1) as avgvalue from table1
    最大:
    select max(field1) as maxvalue from table1
    最小:
    select min(field1) as minvalue from table1
    11
    、说明:几个高级查询运算词

    A
    UNION 运算符
    UNION
    运算符通过组合其他两个结果表(例如 TABLE1 TABLE2)并消去表中任何重复行而派生出一个结果表。当 ALL UNION 一起使用时(即 UNION ALL),不消除重复行。两种情况下,派生表的每一行不是来自 TABLE1 就是来自 TABLE2

    B
    EXCEPT 运算符

    EXCEPT
    运算符通过包括所有在 TABLE1 中但不在 TABLE2 中的行并消除所有重复行而派生出一个结果表。当 ALL EXCEPT 一起使用时 (EXCEPT ALL),不消除重复行。

    C
    INTERSECT 运算符

    INTERSECT
    运算符通过只包括 TABLE1 TABLE2 中都有的行并消除所有重复行而派生出一个结果表。当 ALL INTERSECT 一起使用时 (INTERSECT ALL),不消除重复行。
    注:使用运算词的几个查询结果行必须是一致的。

    12
    、说明:使用外连接

    A
    left outer join

    左外连接(左连接):结果集几包括连接表的匹配行,也包括左连接表的所有行。

    SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c
    B
    right outer join:
    右外连接(右连接):结果集既包括连接表的匹配连接行,也包括右连接表的所有行。

    C
    full outer join

    全外连接:不仅包括符号连接表的匹配行,还包括两个连接表中的所有记录。


    二、提升
    1
    、说明:复制表(只复制结构,源表名:a 新表名:b) (Access可用)
    法一:
    select * into b from a where 1<>1
    法二:
    select top 0 * into b from a
    2
    、说明:拷贝表(拷贝数据,源表名:a 目标表名:b) (Access可用
    )
    insert into b(a, b, c) select d,e,f from b;
    3
    、说明:跨数据库之间表的拷贝(具体数据使用绝对路径) (Access可用
    )
    insert into b(a, b, c) select d,e,f from b in '
    具体数据库' where 条件

    例子:..from b in '"&Server.MapPath(".")&"\data.mdb" &"' where..
    4
    、说明:子查询(表名1a 表名2
    b)
    select a,b,c from a where a IN (select d from b )
    或者
    : select a,b,c from a where a IN (1,2,3)
    5
    、说明:显示文章、提交人和最后回复时间

    select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b
    6
    、说明:外连接查询(表名1a 表名2b)
    select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c
    7
    、说明:在线视图查询(表名1
    a )
    select * from (SELECT a,b,c FROM a) T where t.a > 1;
    8
    、说明:between的用法,between限制查询数据范围时包括了边界值,not between不包括

    select * from table1 where time between time1 and time2
    select a,b,c, from table1 where a not between
    数值1 and 数值2
    9
    、说明:in 的使用方法

    select * from table1 where a [not] in ('
    1','2','4','6')
    10
    、说明:两张关联表,删除主表中已经在副表中没有的信息

    delete from table1 where not exists ( select * from table2 where table1.field1=table2.field1 )
    11
    、说明:四表联查问题:

    select * from a left inner join b on a.a=b.b right inner join c on a.a=c.c inner join d on a.a=d.d where .....
    12
    、说明:日程安排提前五分钟提醒
    SQL: select * from
    日程安排 where datediff('minute',f开始时间
    ,getdate())>5
    13
    、说明:一条sql 语句搞定数据库分页

    select top 10 b.* from (select top 20
    主键字段,排序字段 from 表名 order by 排序字段 desc) a,表名 b where b.主键字段 = a.主键字段 order by a.排序字段
    14
    、说明:前10条记录
    select top 10 * form table1 where
    范围
    15
    、说明:选择在每一组b值相同的数据中对应的a最大的记录的所有信息(类似这样的用法可以用于论坛每月排行榜,每月热销产品分析,按科目成绩排名,等等.)
    select a,b,c from tablename ta where a=(select max(a) from tablename tb where tb.b=ta.b)
    16
    、说明:包括所有在 TableA 中但不在 TableBTableC 中的行并消除所有重复行而派生出一个结果表

    (select a from tableA ) except (select a from tableB) except (select a from tableC)
    17
    、说明:随机取出10条数据
    select top 10 * from tablename order by newid()
    18
    、说明:随机选择记录
    select newid()
    19
    <SPAN style="COLOR: #454545; FONT-FAMILY:

  • QTP基础代码

    wawa133 发布于 2007-03-21 16:10:00

    以下为转载

    这两周我开始学习QTP测试我们的web服务了;大体的软件使用操作流程是懂了,但具体实施起来特别是代码的组织及函数应用还有一些困难,因为自己只会vb没学习vbscrīpt,所以想和大家交流一下代码等一些基础知识;呵呵,一起学习,加强记忆与应用。

    1 生产随机数列
    第一种方法
    randomize'更新反回的数据
    funcation rand(k,n)
    n="int((k-1)*rnd+1) rand=n
    end funcation
    第二种方法
    n="randomnumber.value(1,255)

     2  当运行到表中的某一行,自动导出表中的所有数据
    row=datatable.getcurrentrow
    if row="5" then
      datatable.export("d:\data.xml")
    end if

    3 参数化密码
    webedit("txtpass").setsecure"sdsdf...."
    如果参数化密码,可以直接在数据表中写入未加密的密码,它会自动识别,即不用把setsecure改为set

    4 如果弹出对话框就获取上面提示信息并与表中的信息对比,不统一证明弹出的提示出错,主要用来验证
    if browser("web_name").dialog("dialog_name").exist(1) then'如果不出现="false     error_message=browser("web_name").dialog("diaglog_name").static("用户密码错误!".getRoproperty("text")
       if error_message<>(datatable.value("error_info"))then
             msgbox(error_message)
          end if
         browser("web_name").dialog("diaglog_name").close
      end if
    这里我总结了两点技巧:
      一是:对于dialog中,虽然提示信息对象名称是"用户密码错误",但如果信息对象名称是“该用户不存在”,不用更改会自动识别,我想主要是录制第一遍时,“用户密码错误”只是让运行时能找到这个控制,而不管它是什么内容,因为在对象仓库中,text不是决定该对象的属性
         二是:如果对于提示信息比较长的,可以用mid(error_message,n,m)取一部份特征提示信息进行验证,这样我想可以节省处理时间,又可以避免长度以及空格等字符的处理

    5  datatable.value("num")只在global形式下的一种省略形式;完整形式是:
    datatable.value("num",dtlocalsheet)
    -----向某一列的单元格赋值:
    datatable.value("column_name",dtlocalsheet)="nanjing"
    -----取得某一行具体值:
    datatable.setcurrentrow(n)
    msgbox(datatable.getsheet("global").getparameter("column_name").Rawvalue)
    或者kk=datatable.Rawvalue("column_name","action1")
    ----在run-time时,动态添加表格与数据
    kk=datatable.addsheet("sheet_name").addparameter("column_name","value").name;

    7   wintreeview一些操作
    选择一个条目:wintreeview.select(item)'根是0
    根的名称:wintreeview.getitem(0)

    8   数据库检查点模块:
    sub database_check
    set con="createobject(""adodb.connection")
    con.open "Descrīption="IBM_ODBC;DRIVER=SQL" Server;SERVER="IBM;UID=sa;""&_
                     "PWD="123456;APP=Quick" Test Pro;WSID="IBM;DATABASE=IBM_table""
    'access方式:con.open "DRIVER="{Microsoft" Access Driver (*.mdb)};DBQ="d:\test.mdb""
    'Orocle方式:con.open "DRIVER="{Oracle" in OraHome92};SERVER="CESHI;UID=CND_TEST;PWD=CND;DBQ=CESHI;DBA=W;APA=T;

    EXC=F;XSM=Default;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=Lo;BA

    M=IfAllSuccessful;MTS=F;MDI=Me;CSR=F;FWC=F;PFC=10;TLO=O;""
    set record="createobject(""adodb.recordset")
    sql="select*from ibm_one_table"
    record.open sql,con
    DO
    if(record("ibm_table_column")="kai")then'//查找表格中有多少kai
    num=num+1;
    end if
    record.movenext
    loop until record.eof="true record.close
    set record="nothing con.close
    set con="nothing end sub

    9   换行符
    vbcr----chr(13)回车符// vblf----chr(10)换行符
        vbcrlf----chr(13)+chr(10)结合//type(chr(13)就相当于按了一上键盘上的enter

    10  Run from step有两种方式:
    在Keyword View模式会从本步骤运行到所有action结束
    在expert view模式仅会将本action运行结束

    11  由于对象属性原因,无法识别对象
    -----对于对象属性是变化的,可以参数化/或者用正则表达式
    -----报匹配多个对象错误,可以spy查看对象,添加一个该对象另一个唯一标识属性
    -----有时可以删除对象的变化的属性来解决识别问题
    ------对于多个完全相同的对象,可以采用添加index,location,createtime等特殊属性来识别
      (index:按照程序源码,绘制对象的先后标识对象,所以与其它相同对象是相互依赖,当其它对象发生
      变化后,原先的所有对象index属性要发生变化,开始是0;如index:="0;         location:根据对象的位置进行确定,从上到下,从左到右;
      CreateTime:按照对象被浏览器打开的先后标识对象)
    ------另外换一种思维方式,采取等效的方法;比如用键盘代替鼠标或用操作系统本身特性去解决问题

    12  对系统文件的操作
    -------从系统的文件中获取信息及删除文件
      get_file_infor("c:\she.mpg")
       function get_file_infor(url)
        dim fso,f
        set fso="createobject(""scrīpting.filesystemobject")
        set f="fso.getfile(url)"
        f.name:f.size:f.type:f.datacreated'///获取文件信息
        fso.deletefile(url)'/////删除文件
       end function
    --------获取文件夹里所有文件信息
    get_folder_infor("c:\kai")
    function get_folder_infor(folder)
    dim fso,f,f1,n
    set fso="createobject(""scrīpting,filesystemobject")
    set f="fso.getfolder(folder) set fc="f.files for each f1 in fc
    select case f1.name
    case"kai.mpg","she.mpg","dd.mp3"'//检查文件夹里是否含有这些文件
    end select
    next
    end function

     

    13   等待某个对象出现方法
    y="......waitproperty(""visible",true,10000)

     

    14   防程序中断方法
    On error resume next
    On error goto handle

     

    15  数组的应用:
    name="array(1,2,""aa","bb")
    name(2)="aa"

     

    16  正则表达式应用模板
    进行日期YYYY-MM-DD的格式检查 :
    Function RegExpTest(patrn, strng)
      Dim regEx, Match, Matches      ' Create variable.
      Set regEx = New RegExp         ' Create a regular expression.
      regEx.Pattern = patrn         ' Set pattern.
      regEx.IgnoreCase = True         ' Set case insensitivity.
      regEx.Global = True         ' Set global applicability.
      Set Matches = regEx.Execute(strng)   ' Execute search.
      For Each Match in Matches      ' Iterate Matches collection.
        RetStr = RetStr & "Match found at position "
        RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
        RetStr = RetStr & Match.Value & "'." & vbCRLF
      Next
      RegExpTest = RetStr
    End Function
    date_pattern="^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((01,3-9])|(1[0-2]))-(29|30)))))$"
    result_message=RegExpTest(date_pattern, inputbox("请你输入要检查的时间:"))'用其它正则表达式更改此处
    Select case result_message
    Case ""
             msgbox("你输入的日期格式与标准不匹配")
    case else  MsgBox(result_message)
    end select

     

    17   返回一个字符串在另一字符串中的位置
    instr(string1,string2)

     

    18   有时回放出现找不到对象时,可能不是由于你的代码问题,而是由于你的操作系统等设置问题;
    举例说明1:
    比如:你录制一个选择磁盘中的文件动作
    会录制为:
    .winlistview("  ").drap 46,99
    .winlistview("  ").draponitem "she.mp3"
    下次录制的时候,如果你的系统文件改为不显示扩展名,下次执行的时候,QTP就找不到she.mp3,只能找到she;
    举例说明2:
    有时由于不同操作系统以及不同的ie,导致有些窗口不能识别,比如在2000下弹出的网页对话框的标题是:
    “web对话框",而在2003上是”网页对话框"

     

    19  "is+*"类型function
    isarray'是否是数组
    isconnected'判断QTP是否连接到TD
    isdate'是否是合法的日期类型
    isempty'判断是否初始化
    isNull'判断是否为空值
    isNumeric'判断是否是数字型
    isobject'判断是否一个功能对象
    isready'判断设备是否准备就绪
    isRootFolder'是否是根目录

     

    20 Action之间的参数传递
    例如:在Action1中,有如下代码:
    out_str="This is out_string"
    RunAction "Action2",oneIteration,out_str
    在Acton2中,在其step->Action Properties中的,input参数栏,加入out_str后,
    msgbox(parameter("out_str")),就能正确显示参数了 

     

    21 Wscrīpt.Shell的一些应用
    set WshShell ="CreateObject(""Wscrīpt.Shell")
    WshShell.SendKeys "{ENTER}"     '模拟键盘进行操作
    WshShell.AppActivate "Calculator"             '启动应用程序

     

    22 获取对象属性名称用法:
    GetRoProperty----从应用程序界面上获取对象属性(即,是脚本运行时,获取的对象动态属性值)例如:获取对象库中index属性值,似乎只能用GetToProperty,因为应用程序界面上对象没有该属性,只是QTP为识别该对象创立的描述属性;
    GetToproperty----从对象库中描述对象的属性,静态值
    GetToProperties----获取用于标识对象的属性集;对于这个集合,有count等属性方法

     

    23 FireEvent的使用可以对一个对象进行更复杂的操作
    如:FireEvent("onfocus")   '使一个控件获取焦点
         FireEvent("ondblclick")  '实现双击/也可以在事件设定中针对该对象事件响应  

     

    24 模板的应用
    -----新建一个文本,输入一些新建Action时常包含的信息,然后保存为ActionTemplate.MST文件,
     并复制到QTP/dat目录下;这样每次新建action都会包含固定的信息了;
    例如:
    '-------------------脚本说明---------------
    '产品版本:      __Build(  )
    '测试员:
    '编写日期:
    '测试功能:
    '脚本类型:
    '被测试对象初始状态:
    '进展程度:
    '基本思路:
    '主要功能函数:
    '历史修改:
    '没解决的问题:
    '--------------------脚本内容-------------

     

    25 在对象库中,两个对象有时不能通过更改属性或命名来达到两个对象完全一致的替换;
    在web-mod项目中,我在对象库里添加了一个自动含有index标识属性的对象,然后每次通过SetToproperty来改变
    index值,对对象进行数据驱动,使其操作另一个对象,但脚本始终操作原先index属性值的对象;后来,把该对象
    删除掉,重新添加一个不自动含有index标识属性的该类对象,然后,手工添加,index标识属性,后来脚本能正常工作了,可见两次的对象属性完全一致,但形成方式不一样,导致的结果往往也不一样;

     

    26 childobject的应用
    childobject可以返回界面上满足条件的对象集合,而且与对象库里是否有这些对象无关,这就可以简化对象库;
    返回的对象集合的count方法可以返回对象个数,这就可以通过下标对单个对象进行操作;在出现index标识对象时
    可以进行运用
    如:Set m_WinCheck="Descrīption.Create()       m_WinCheck("nativeclass").Value="Button"
          set All_WinCheck="Window(""").Dialog("").Childobject(m_WinCheck)
          n="All_WinCheck.Count()      for i="0" to n-1
          All_WinCheck(i).Set "ON"
         next

  • VBScript中SendKeys的妙用

    coletan 发布于 2007-08-26 02:42:53

    【转载自(sidneylover的空间】

    什么是VBscrīpt呢?

    VBscrīpt的全称是:Microsoft Visual Basic scrīpt Editon.(微软公司可视化BASIC脚本版). VBS(VBscrīpt的进一步简写)是基于Visual Basic的脚本语言,其不编译成二进制文件, 而是直接由宿主(host)解释源代码并执行, 简单点说就是你写的程序不需要编译成.exe, 而是直接给用户发送.vbs的源程序, 用户就能执行了.

    SendKeys 方法

    模拟键盘操作,将一个或多个按键指令发送到指定Windows窗口来控制应用程序运行, 
    其使用格式为:object.SendKeys(string) 

    “object”:表示WshShell对象 
    “string”:表示要发送的按键指令字符串,需要放在英文双引号中。

    -----------------------------------
    1.基本键 

      一般来说,要发送的按键指令都可以直接用该按键字符本身来表示,例如要发送字母“x”,使用“WshShell.SendKeys "x"”即可。当然,也可直接发送多个按键指令,只需要将按键字符按顺序排列在一起即可,例如,要发送按键“happy”,可以使用“ WshShell.SendKeys "happy" ”。

    2.特殊功能键 

      对于需要与Shift、Ctrl、Alt三个控制键组合的按键,SendKeys使用特殊字符来表示: 

      Shift---------WshShell.SendKeys "+" 
      Ctrl---------WshShell.SendKeys "^" 
      Alt---------WshShell.SendKeys "%"  (注意   这样使用时,不用大括号括起这些特殊字符。)
      由于“+”、“^”这些字符用来表示特殊的控制按键了,如何表示这些按键呢? 只要用大括号括住这些字符即可。例如: 要发送加号“+”,可使用“WshShell.SendKeys "{+}"” 

    另外对于一些不会生成字符的控制功能按键,也同样需要使用大括号括起来按键的名称。
    例如要发送回车键,需要用“ WshShell.SendKeys "{ENTER}" ”表示;
    发送向下的方向键用“ Wshell.SendKeys "{DOWN}" ”表示。 

    Space---------WshShell.SendKeys " " 
    Enter---------WshShell.SendKeys "{ENTER}" 
    ←---------WshShell.SendKeys "{RIGHT}" 
    ↑---------WshShell.SendKeys "{UP}" 
    F1---------WshShell.SendKeys "{F1}" 

    按键                代码    
    BACKSPACE     {BACKSPACE}, {BS}, 或 {BKSP}    
    BREAK         {BREAK}    
    CAPS LOCK     {CAPSLOCK}    
    DEL or Delete {Delete} 或 {DEL}    
    DOWN ARROW    {DOWN}    
    END           {END}    
    ENTER         {ENTER}或 ~    
    ESC           {ESC}    
    HELP          {HELP}    
    HOME          {HOME}    
    INS or Insert {Insert} 或 {INS}    
    LEFT ARROW    {LEFT}    
    NUM LOCK      {NUMLOCK}    
    PAGE DOWN     {PGDN}    
    PAGE UP       {PGUP}    
    PRINT SCREEN  {PRTSC}    
    RIGHT ARROW   {RIGHT}    
    SCROLL LOCK   {SCROLLLOCK}    
    TAB           {TAB}    
    UP ARROW      {UP}    
    F1 {F1}    
    F2 {F2}    
    F3 {F3}    
    F4 {F4}    
    F5 {F5}    
    F6 {F6}    
    F7 {F7}    
    F8 {F8}    
    F9 {F9}    
    F10 {F10}

    Tips:如果需要发送多个重复的单字母按键,不必重复输入该字母,SendKeys允许使用简化格式进行描述,使用格式为“{按键 数字}”。例如要发送10个字母“x”,则输入“WshShell.SendKeys "{x 10}"”即可。

    -----------------------------------
    按下F5刷新桌面 

    Dim WshShell,Path,i 
    Set WshShell = Wscrīpt.CreateObject("Wscrīpt.Shell") 
    WshShell.SendKeys "{F5}" 
    ---------------------------------------------------- 
    电脑的自动重启 

    set WshShell = CreateObject("Wscrīpt.Shell") 
    WshShell.SendKeys "^{ESC}u" 
    WshShell.SendKeys "R" 
    ---------------------------------------------------- 
    启动任务管理器 

    set WshShell = CreateObject("Wscrīpt.Shell") 
    WshShell.SendKeys "^+{ESC}" 
    ---------------------------------------------------- 
    QQ消息连发 

    Dim WshShell 
    Set WshShell= Wscrīpt.createObject("Wscrīpt.Shell") 
    WshShell.AppActivate "bomb" 
    for i=1 to 60 
    Wscrīpt.Sleep 800 
    WshShell.SendKeys "What do you say" 
    WshShell.SendKeys i 
    WshShell.SendKeys "%s" 
    next 
    ---------------------------------------------------- 
    自动到百度搜索歌曲:white flag 

    Dim WshShell,Path,i 
    Set WshShell = Wscrīpt.CreateObject("Wscrīpt.Shell") 
    WshShell.Run("IEXPLORE.EXE") 
    Wscrīpt.Sleep 2000 
    WshShell.AppActivate "about:blank-Microsoft Internet Explorer" 
    WshShell.SendKeys "+{TAB}" 
    WshShell.SendKeys "http://mp3.baidu.com
    Wscrīpt.Sleep 800 
    WshShell.SendKeys "{ENTER}" 
    Wscrīpt.Sleep 3000 
    WshShell.SendKeys "white flag" 
    Wscrīpt.Sleep 800 
    WshShell.SendKeys "{ENTER}" 
    ---------------------------------------------------- 
    自动关机

    Dim WshShell
    Set WshShell=Wscrīpt.CreateObject("Wscrīpt.Shell")
    Wscrīpt.Sleep 2000
    WshShell.Run "shutdown -r -t 120"
    wscrīpt.sleep 6000
    WshShell.Run "shutdown -a"
    ---------------------------------------------------- 
    在记事本中输入Happy Birthday!并保存为birth.txt 

    Dim WshShell 
    Set WshShell=Wscrīpt.CreateObject("Wscrīpt.Shell") 
    WshShell.Run "notepad" 
    Wscrīpt.Sleep 1500 
    WshShell.AppActivate "无标题 - 记事本" 
    WshShell.SendKeys "H" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "a" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "p" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "p" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "y" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys " " 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "B" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "i" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "r" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "t" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "h" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "d" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "a" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "y" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "!" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "%FS" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "b" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "i" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "r" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "t" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "h" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "%S" 
    Wscrīpt.Sleep 500 
    WshShell.SendKeys "%FX" 
    ---------------------------------------------------- 
    制作能自动定时存盘的记事本 

    '第一部分:定义变量和对象 

    Dim WshShell, AutoSaveTime, TXTFileName 
    AutoSaveTime=300000 
    Set WshShell=Wscrīpt.CreateObject("Wscrīpt.Shell") 
    TXTFileName=InputBox("请输入你要创建的文件名(不能用中文和纯数字):") 

    '第二部分:打开并激活记事本 

    WshShell.Run "notepad" 
    Wscrīpt.Sleep 200 
    WshShell.AppActivate "无标题 - 记事本" 

    '第三部分:用输入的文件名存盘 

    WshShell.SendKeys "^s" 
    Wscrīpt.Sleep 300 
    WshShell.SendKeys TXTFileName 
    Wscrīpt.Sleep 300 
    WshShell.SendKeys "%s" 
    Wscrīpt.Sleep AutoSaveTime 
    '第四部分:自动定时存盘 
    While WshShell.AppActivate (TXTFileName)=True 
    WshShell.SendKeys "^s" 
    Wscrīpt.Sleep AutoSaveTime 
    Wend 
    Wscrīpt.Quit 

     

    自动死机o(∩_∩)o...

    DIM WSHSHELL 
    SET WSHSHELL=Wscrīpt.CreateOBJECT("Wscrīpt.SHELL") 
    'WSHSHELL.RUN " " 
    'Wscrīpt.SLEEP 1000 
    WSHSHELL.SENDKEYS "{ENTER}" 
    'Wscrīpt.SLEEP 1000 
    WSHSHELL.SENDKEYS "{ENTER}" 
    'Wscrīpt.SLEEP 1000 
    WSHSHELL.SENDKEYS "{ENTER}" 
    'Wscrīpt.SLEEP 1000 
    WSHSHELL.SENDKEYS "{ENTER}" 
    'Wscrīpt.SLEEP 1000 
    WSHSHELL.SENDKEYS "{ENTER}" 

    [/quote]


     

     

  • QTP识别和操作对象的原理

    coletan 发布于 2007-08-26 00:49:12

    【转载自(红霞小洼的空间)】

    QTP为用户提供了两种操作对象的接口,一种就是对象的封装接口,另一种是对象的自身接口。
    对象的自身接口是对象控件本身的接口,只要做过软件开发,使用过控件的人应该很清楚。
    对象的封装接口是QTP为对象封装的另一层接口,它是QTP通过调用对象的自身接口来实现的。


    两种接口的脚本书写格式的差别在于:
      自身接口需要在对象名后面加object再加属性名或方法名,
      封装接口就不用在对象名后面加object。

    比如操作JavaEdit对象,通过QTP封装的封装接口,脚本如下:
      设置JavaEdit的内容:
         JavaDialog("Add NE").JavaEdit("NE Name").Set "NE1"
      读取JavaEdit的内容:
         msgbox JavaDialog("Add NE").JavaEdit("NE Name").GetROProperty("value")

    如果通过JavaEdit的自身接口,脚本如下:
      设置JavaEdit的内容:
         JavaDialog("Add NE").JavaEdit("NE Name").object.setText("NE1")
      读取JavaEdit的内容:
         Msgbox JavaDialog("Add NE").JavaEdit("NE Name").object.getText()

    QTP执行JavaEdit().Set语句时,是通过执行JavaEdit().object.setText()来实现的。
    QTP执行JavaEdit().GetROProperty("value"),是通过执行JavaEdit().object.getText()来实现的。
    JavaEdit对象的封装接口Set()和GetROProperty("value"),是QTP封装JavaEdit对象的自身接口setText()和getText()而得来的。

    对象的封装接口是QTP使用的缺省接口,我们录制出来的脚本都是使用封装接口,大家用的也都是封装接口。
    但是封装接口不如自身接口丰富,因为QTP只是封装了部分常用的自身接口嘛。
    所以我们在需要时,可以绕过封装接口,直接调用对象的自身接口。
    不过有些自身接口不够稳定,在实践中偶尔会出现问题,但是概率很少。
    封装接口有相应功能的话,就尽量用封装接口吧!


    理解了封装接口和自身接口的原理,我们就可以更加灵活的操作对象了。

    但是我们怎么知道对象都有哪些封装接口和自身接口呢?
    其实很简单,用对象查看器(Object Spy)查看对象,在查看窗口里有列出这些接口,包括属性和方法。
    窗口中间有选择栏让你选择Run-time Object或者Test Object,
    当你选择Run-time Object时,它显示的就是对象的自身接口(自身的属性和方法)
    当你选择Test Object时,它显示的就是对象的封装接口(封装的属性和方法)

    明白了这些,你还等什么呢?快拿起对象查看器,看看对象都有哪些封装接口和自身接口,肆意的操作它,玩弄它吧!

    比如执行
      JavaDialog("Add NE").JavaEdit("NE Name").object.setVisible(false)
    哈哈,你的JavaEdit对象就当场消失不见了!!!

     

  • GetROProperty,GetTOProperties,GetTOProperty的区别

    coletan 发布于 2007-08-26 00:49:53

    【转载自(红霞小洼的空间)】

    应该说TO是仓库文件里定义的仓库对象,RO是被测试软件的实际对象
    QTP要求先在仓库文件里定义仓库对象,里面存有实际对象的特征属性的值,
    运行的时候,QTP会根据仓库对象的特征属性描述,寻找到实际对象,然后操作实际对象。

    仓库对象TO一般在录制/编写脚本时加入仓库文件,它不仅可以在编写时进行修改,
    也可以在运行过程中进行动态修改,以匹配实际对象。

    相关的几个函数有:

    GetTOProperty():取得仓库对象的某个属性的值
    GetTOProperties():取得仓库对象的所有属性的值
    SetTOProperty():设置仓库对象的某个属性的值
    GetROProperty():取得实际对象的某个属性的值


    理解了TO的含义,你就可以自由的用SetTOProperty()定义TO,以灵活的操作RO

    比如有个测试任务,窗口上有很多待检查的记录,每条记录右边都有一个Check按钮,用来检查各条记录。
    记录个数不定,所以Check按钮个数也就不定,只有一个Edit显示记录个数。
    我们要对每条记录进行检查,也就是要点击每个Check按钮。
    但是Check按钮个数不定,不好录制,而且个数可能也很多(上百个),即使能一一录制,那也很麻烦。

    那我有一个好办法,只录制一个按钮对象,它设有两个特征属性 label=OK, index=0
    然后用下面的脚本,就可以完成测试

    buttonNum = CInt(JavaWindow("Test").JavaEdit("Record Num").GetROProperty("value"))
    For buttonIndex = 0 to buttonNum - 1
      JavaWindow("Test").JavaButton("Check").SetTOProperty("index", buttonIndex)
      JavaWindow("Test").JavaButton("Check").Click
    Next


    或者窗口上有New、Modify、Delete、Check等好几个按钮,要把这几个按钮一一按过去
    我在对象仓库里只设置一个按钮对象AnyButton,label特征属性值填任意值,然后用下面脚本执行测试

    JavaWindow("Test").JavaButton("AnyButton").SetTOProperty("label", "New")
    JavaWindow("Test").JavaButton("AnyButton").Click

    JavaWindow("Test").JavaButton("AnyButton").SetTOProperty("label", "Modify")
    JavaWindow("Test").JavaButton("AnyButton").Click

    JavaWindow("Test").JavaButton("AnyButton").SetTOProperty("label", "Delete")
    JavaWindow("Test").JavaButton("AnyButton").Click

    JavaWindow("Test").JavaButton("AnyButton").SetTOProperty("label", "Check")
    JavaWindow("Test").JavaButton("AnyButton").Click


    另外,QTP还支持脚本描述的方法来定义和访问对象,即不需要在仓库里定义,也能访问和操作实际对象

    如上面两个任务,可以如下实现

    1. 不需要在仓库里定义Check按钮对象,直接用下面脚本来实现测试

    buttonNum = CInt(JavaWindow("Test").JavaEdit("Record Num").GetROProperty("value"))
    For buttonIndex = 0 to buttonNum - 1
      JavaWindow("Test").JavaButton("label:=Check", "index:="+CStr(buttonIndex)).Click
    Next

    2. 不需要在仓库里定义New、Modify、Delete、Check按钮对象,直接用下面脚本来实现测试

    JavaWindow("Test").JavaButton("label:=New").Click
    JavaWindow("Test").JavaButton("label:=Modify").Click
    JavaWindow("Test").JavaButton("label:=Delete").Click
    JavaWindow("Test").JavaButton("label:=Check").Click

  • QTP的一些小知识

    xiaonan 发布于 2006-12-01 09:16:06

    1.GetCellData函数 

      作用:获取单元格的值

      例:  rowCount = Browser("xxx ").Page("xxx ").Frame("xxx").WebTable("xxx").RowCount
    For counter = 1 To rowCount
      text = Browser("xxx").Page("xxx").Frame("xxx").WebTable("xxx").GetCellData(counter,1)
      If (text = "xxx") Then
        counter = counter - 1
        selectNO = "#" & counter
        Browser("xxx").Page("xxx").Frame("xxx").WebRadioGroup("xxx").Select selectNO
        Exit For
      End If
    Next

    2.把值插入datatable里

      例:   datatable.setcurrentrow(i)
            datatable.value("name","Global")="name"
            datatable.value("passwd","Global")="passwd"

    3.用代码来启动浏览器

      Browser1 = "IE"
      StartURL = "www.51testing.com"
      IF Browser1 = "IE" THEN
         set IE = CreateObject("InternetExplorer.Application")
         IE.Visible = true
         IE.Navigate StartURL
      END IF
     

    4.ExecuteFile函数

      作用:ExecuteFile 可以直接执行vbs文件,而不需要将其导入resource中 
           ExecuteFile FileName 
      说明:where FileName is the absolute or relative path of your VBscrīpt file.

      例:ExecuteFile("F:\test.vbs")

    5.Strcomp函数 

      作用:比较文本

      例:dim strtext1,strtext2,str ,str1,comp1
         strtext1 = "xxx"
         strtext2 = "xxx"
         str = VbWindow("xxx").VbWindow("xxx").VbLabe1("xxx").GetTOProperty("text")
         str1= VbWindow("xxx").VbWindow("xxx").VbLabel("xxx").GetTOProperty("text")
         comp1=strcomp(strtext1,str,0)
         If  comp=0 Then
              msgbox “这两个串相等”
         else
           msgbox str
         End If 

    6.CaptureBitmap 

      作用:捕获屏幕

    7. GetROProperty

      作用:取对象属性值

      例:VbWindow("xxx").VbWindow("xxx").VbWindow("xxx").ActiveX("xxx").GetROProperty("TextMatrix(1,0)") 

    8.ExitAction - 退出当前操作,无论其循环属性如何。
      ExitActionIteration - 退出操作的当前循环。
      ExitRun - 退出测试,无论其循环属性如何。
      ExitGlobalIteration - 退出当前全局循环。


    9.如何使用Excel对象处理数据?
      Dim xl
      打开excel文件
      Function OpenExcelFile(strFilePath)
      Set xl = CreateObject("Excel.Application")
      xl.Workbooks.Open strFilePath
      End Function
      获得指定单元格数据
      Function GetCellData(strSheet,rwIndex,colIndex)
      GetCellData = xl.WorkSheets(strSheet).Cells(rwIndex,colIndex)
      End Function
      填充单元格数据
      Function PutCellData(strSheet,rwIndex,colIndex,varData)
      xl.WorkSheets(strSheet).Cells(rwIndex,colIndex) = varData
      End Function
      保存并推出
      Function SaveAndQuit()
      xl.Activeworkbook.save
      xl.Quit
      Set xl = nothing
      End Function

    10.连接sql数据库

      例:Dim res,cmd,sql
         Set Res=createobject("adodb.recordset")
         Set Cmd=createobject("adodb.command")
         Cmd.activeconnection="Provider=SQLOLEDB.1;Password=111111;Persist Security Info=True;User ID=sa;Initial Catalog=xhq;Data Source=192.168.191.142"  '这句话是连接数据库的数据源,要做修改
        Cmd.CommandType = 1
        sql="selec t * from 表 where name=username"
        Cmd.CommandText = sql
        Set res = Cmd.Execute()
        Set res = nothing
        Set cmd.ActiveConnection = nothing
        Set Cmd= nothing

19410/10<12345678910
Open Toolbar