欢迎到访!

发布新日志

  • [转]WinRunner的问题整理

    jzhao 发布于 2007-01-11 11:05:05

    WinRunner的问题整理
    文章出处:51testing论坛 作者:朴春龙 发布时间:2005-11-24
    多数问题是在MSN上,论坛上其他测试人员提出的问题,我回答后发现很多人问到同样的问题,这里整理了一下希望对大家有帮助!

    1.WinRunner如何把Real类型转化为指数表示方法
    答:
       指数类型转化为real类型,可以通过下边的代码
       var = 5.3569E+10;
       pause(var);
       #显示 53569000000
       
       Real类型转化为指数表示方式
       var = sprintf("%e",53568544768);
       pause(var);
       #displays 5.356854e+010

    2.什么是同步点,怎样用它?他和Wait有什么不同?
    答: 从功能上他们都可以实现脚本和被测试程序同步的问题,不过同步点有window/object,bitmap方式,她等待的是某个等待的对象     窗体,bitmap的出现,一定程度她也可以作为验证点
         wait这点上无法实现相同的效果。有的脚本中即使你加入wait,但是你无法知道下边的对象窗体图片是否就是成需要运行的正确     出现的
    3.tl_step和tl_step_once的区别
    答:tl_step和tl_step_once都是把运行状态信息放到运行结果中去,区别在如果连接TD,TL_STEP把每步状态信息都插入到测试结果中去,tl_step_once如果连接td,只是插入一次运行步骤的名字
       
    代码例子:
    --------------------------------------------------------------------------------

    for (i=1;i<4;i++){  
         tl_step("Step", PASS, "reporting step, #" &i);  
         tl_step_once("Step Once", PASS, "reporting step once, #" &i);
    }

    --------------------------------------------------------------------------------

    WR中的报告:
    Step: Step, Status: PASS, Descrīption: reporting step, #1
    Step: Step Once, Status: PASS, Descrīption: reporting step once, #1
    Step: Step, Status: PASS, Descrīption: reporting step, #2
    Step: Step Once, Status: PASS, Descrīption: reporting step once, #2
    Step: Step, Status: PASS, Descrīption: reporting step, #3
    Step: Step Once, Status: PASS, Descrīption: reporting step once, #3

    TD中的报告:
    Step: Step, Status: PASS, Descrīption: reporting step, #1
    Step: Step Once, Status: PASS, Descrīption: reporting step once, #1
    Step: Step, Status: PASS, Descrīption: reporting step, #2
    Step: Step, Status: PASS, Descrīption: reporting step, #3

    4.WinRunner和TD集成后脚本运行很慢是什么原因呢?
    答:安装TD和WinRunner服务器上需要独占100GByte,TD需要10OGHZ时钟速度16GB RAM的处理平台

    5.WR是否支持vs.net
      根据Mercury的介绍,他们的对.Net的支持转移到QuickTest Pro上了,如果你需要自动化测试.Net程序(不是web的),建议用

    QuickTestPro。也就是说wr不支持vs.net开发的程序

    6.我对比两个文件file1.txt和file2.txt,文本内容如下
      file1.txt 内容如下:
      10523 8315 6804 8387 3643 4550 3457 3649

      file2.txt内容如下:
      190176 155737 117417 145194 65314 81431 64522 63324
      
      代码如下:file_compare("C:\\file1.txt","C:\\file2.txt","save");
      为什么每次对比这两个文件结果都是通过的。
    答:这个问题的原因在于它在前面的脚本中对文件进行了操作,没有关闭,所以这段代码运行总是通过

    7.如何在winRunner中用Windows的API函数
      在使用该API函数前需要先加载该函数然后声明API函数,代码如下
    load_dll("user32.dll");
    extern int PostMessageA(in long, in long, in long, in long);
    win_get_info("{class:window, MSW_class:AfxMDIFrame42, label:\"!WinRunner.*\"}", "handle", hWnd);
    PostMessageA(hWnd, 16, 0, 0);

    请在尝试以上代码的时候,保存脚本,呵呵!  

    8.怎样处理跟踪键盘操作?
    答:下边的代码希望对你有帮助
        function GetKeyStatus(in vKey){  
          auto pid, thread_id, win_desc, hWnd, KeyState, win_log_name, win_full_desc, focused_obj_desc;
          win_desc = "{active:1}";       
          if (win_exists(win_desc)==0)        {           
             win_get_desc(win_desc, "", "", "", win_full_desc);
                    GUI_map_get_logical_name( win_full_desc, "", win_log_name, "bla");
                 win_get_info(win_desc, "handle", hWnd);
                  pid = GetWindowThreadProcessId(hWnd, NULL);
                thread_id=GetCurrentThreadId();
                   AttachThreadInput(pid,thread_id,TRUE);
                 KeyState=GetKeyState (vKey);
                AttachThreadInput(pid,thread_id,FALSE);
                 if (KeyState < 0)              
                return(0); # Key is pressed
               else           
                return (1); # Key is not pressed       
            }
            else
                    return (-1); # No active window found, so cannot determine key state
        }

    9.WinRunner如何处理excel?
    答:其实解决方法有很多,这里列举两种。
       一.利用其他语言特性开发出dll提供给winrunner使用(vb,vc,delphi等)
       二.在其他环境中实现,用winrunner调用
       第一种我在这里不举例子了,第二种我利用vbs往excel中赋值给大家提供一种思路,代码如下:

    'vbs中的代码
       Dim ExcelApp
       Dim itemX
       if Wscrīpt.Arguments.Count < 2 then
        r = msgbox("Requires 2 arguments", 48, "change_sheet")
       else
        dim fso
        set fso = createobject("scrīpting.filesystemobject")
        xlBook = fso.GetAbsolutePathName(Wscrīpt.Arguments(0))
        xlSheet = Wscrīpt.Arguments(1)
        set fso = Nothing
        Set ExcelApp = CreateObject("Excel.Application")
        ExcelApp.Workbooks.Open(xlBook)
        Set itemX = ExcelApp.ActiveWorkbook.Worksheets.Item(xlSheet)
        itemX.Activate
       
        excelApp.ActiveWorkbook.Worksheets(xlSheet).Range("A1").Select
        excelapp.ActiveCell.FormulaR1C1 = "1"
        excelApp.ActiveWorkbook.Worksheets(xlSheet).Range("B1").Select
        excelapp.ActiveCell.FormulaR1C1 = "2"
        excelApp.ActiveWorkbook.Worksheets(xlSheet).Range("c1").Select
        excelapp.ActiveCell.FormulaR1C1 = "3"

        ExcelApp.ActiveWorkbook.Save()
        ExcelApp.ActiveWorkbook.Close(1)
        ExcelApp.Quit()
       
        Set itemX = Nothing
        Set ExcelApp = Nothing

    end if

    winrunner中的调用代码:
    dos_system("wscrīpt \"C:\\excel_sheet.vbs\" \"C:\\SheetBook.xls\" \"Sheet2\"");  
       
    10.在WinRunner中如何实现得到transaction时间?
    答:一般情况下transaction的时间只能在最后结果中得到,如何在脚本得到这个时间呢,下边的代码可以

    帮助你:
    public transactions[];
    function start_my_transaction(in transaction_name)
    {
            transactions[transaction_name] = get_time();
            tl_step("Start transaction: \"" & transaction_name & "\"",PASS,"Timestamp: " &

    transactions[transaction_name]);
            return (transactions[transaction_name]);
    }
    function end_my_transaction(in transaction_name)
    {
            auto end_time = get_time();
            auto rc;
            if(transactions[transaction_name] == "")
            {
                    tl_step("End transaction: \"" & transaction_name & "\"",FAIL,"Transaction was

    never started.");
                    rc =  -1;
            }
            else
                    tl_step("End transaction: \"" & transaction_name & "\"",PASS,"Elapsed Time: "

    & (rc =  end_time - transactions[transaction_name]));
            delete transactions[transaction_name];
            return rc;
    }

    start_my_transaction("my_transaction");
    wait(2);
    rc = end_my_transaction("my_transaction");
    pause("Elapsed time = " & rc);
  • 测试工具大全(各类测试工具简介)转载

    syn106 发布于 2007-08-10 13:48:59

    企业级自动化测试工具WinRunner

     

    提名理由:Mercury Interactive公司的WinRunner是一种企业级的功能测试工具,用于检测应用程序是否能够达到预期的功能及正常运行。通过自动录制、检测和回放用户的应用操作,WinRunner能够有效地帮助测试人员对复杂的企业级应用的不同发布版进行测试,提高测试人员的工作效率和质量,确保跨平台的、复杂的企业级应用无故障发布及长期稳定运行。

    工业标准级负载测试工具Loadrunner

     

    提名理由:LoadRunner 是一种预测系统行为和性能的负载测试工具。通过以模拟上千万用户实施并发负载及实时性能监测的方式来确认和查找问题,LoadRunner 能够对整个企业架构进行测试。通过使用LoadRunner ,企业能最大限度地缩短测试时间,优化性能和加速应用系统的发布周期。

    全球测试管理系统testdirector

     

    提名理由:TestDirector 是业界第一个基于Web的测试管理系统,它可以在您公司内部或外部进行全球范围内测试的管理。通过在一个整体的应用系统中集成了测试管理的各个部分,包括需求管理,测试计划,测试执行以及错误跟踪等功能,TestDirector极大地加速了测试过程。

    功能测试工具Rational Robot

     

    提名理由:IBM Rational Robot 是业界最顶尖的功能测试工具,它甚至可以在测试人员学习高级脚本技术之前帮助其进行成功的测试。它集成在测试人员的桌面 IBM Rational TestManager 上,在这里测试人员可以计划、组织、执行、管理和报告所有测试活动,包括手动测试报告。这种测试和管理的双重功能是自动化测试的理想开始。

    单元测试工具xUnit系列

     

    提名理由:目前的最流行的单元测试工具是xUnit系列框架,常用的根据语言不同分为JUnit(java),CppUnit(C++),DUnit (Delphi ),NUnit(.net),PhpUnit(Php )等等。该测试框架的第一个和最杰出的应用就是由Erich Gamma (《设计模式》的作者)和Kent Beck(XP(Extreme Programming)的创始人 )提供的开放源代码的JUnit。

    功能测试工具SilkTest

     

    提名理由:Borland SilkTest 2006属于软件功能测试工具,是Borland公司所提出软件质量管理解决方案的套件之一。这个工具采用精灵设定与自动化执行测试,无论是程序设计新手或资深的专家都能快速建立功能测试,并分析功能错误。 

    性能测试工具WAS

     

    提名理由:Microsoft Web Application Stress Tool 是由微软的网站测试人员所开发,专门用来进行实际网站压力测试的一套工具。透过这套功能强大的压力测试工具,您可以使用少量的Client端计算机仿真大量用户上线对网站服务所可能造成的影响。

    自动化白盒测试工具Jtest

     

    提名理由:Jtest是parasoft公司推出的一款针对java语言的自动化白盒测试工具,它通过自动实现java的单元测试和代码标准校验,来提高代码的可靠性。parasoft同时出品的还有C++ test,是一款C/C++白盒测试工具。

    功能和性能测试的工具JMeter

     

    提名理由:JMeter是Apache组织的开放源代码项目,它是功能和性能测试的工具,100%的用java实现。

    性能测试和分析工具WEBLODE

     

    提名理由:webload是RadView公司推出的一个性能测试和分析工具,它让web应用程序开发者自动执行压力测试;webload通过模拟真实用户的操作,生成压力负载来测试web的性能。

     测试工具大全

    Author: Vince

    工具类别 工具名称 生产厂商 相关网站
    通用功能自动化测试工具 Winrunner Mercury
    Quicktest pro Mercury
    Xrunner Mercury
    QARun Compuware
    TestPartner Compuware
    WebKing Parasoft http://www.parasoft.com
    Robot IBM Rational http://www.ibm.com/cn
    Visual Test IBM Rational http://www.ibm.com/cn
    Functional Tester IBM Rational http://www.ibm.com/cn
    SilkTest Segue
    SilkTest International Segue
    e-Tester Empirix
    WebFT Radview
    TestComplete AutomatedQA
    QA Wizard Seapine
    Software EggPlant RedStone
    Test Edition Microsoft Visual Studio
    PureTest Minq
    Autotester Autotester
    Testbench400 Original Software
    TestExpert VEReCOMM
    TestRunner Qronus
    TTCN suite Telelogic http://www.telelogic.com.cn
    QC/Replay Centerline
    Web AutoTester
    eValid Software Research
    WebART OCLC
    MaxQ 开源
    WebInject 开源
    Marathon 开源
    性能测试/监控工具  LoadRunner Mercury
    SiteScope Mercury
    Topaz Mercury
    QaLoad Compuware
    PerformaSure/benchmark Quest
    Silkperformer Segue
    Silkperformer Lite Segue
    SilkCentralTM Performance Manager Segue
    e-Load Empirix
    Robot IBM Rational http://www.ibm.com/cn
    Performance Tester IBM Rational http://www.ibm.com/cn
    WebLoad RadView
    Web applicaton stress tool  Microsoft
    Application center test Microsoft
    PureLoad Minq
    Athene APR Metron
    ForeCast Facilita
    Impact/Impact for CBT Cyrano
    Berkeley Laboratory sniffer Lawrence
    Jmeter 开源
    openSTA 开源
    Siege 开源
    StressMark 开源
    DBMonster 开源
    白盒测试/代码分析工具  VcTester ezTester http://www.eztester.com
    Jtest Parasoft http://www.parasoft.com
    C++test Parasoft http://www.parasoft.com
    SOA test Parasoft http://www.parasoft.com
    .test Parasoft http://www.parasoft.com
    Codewizard Parasoft http://www.parasoft.com
    Insure++ Parasoft http://www.parasoft.com
    DataRecon Parasoft http://www.parasoft.com
    Numega devpartner studio Compuware
    DevPartnerJavaEdition Compuware
    BoundsChecker Compuware
    SmartCheck Compuware
    DBPartner Compuware
    Bean-test Empirix
    Aqtime AutomatedQA
    QESatJava AutomatedQA
    Visual Unit Unitware
    PC-lint Gimpel Software
    Macabe Macabe
    Optimizeit Suite Borland
    JProbe Suite Quest Software
    Application assurance suite Quest Software
    Sql optimizer Quest Software
    Jprofiler ej-technologies
    workbench Cyrano
    Logiscope TeleLogic http://www.telelogic.com.cn
    rulecheck TeleLogic http://www.telelogic.com.cn
    SilkPerformer Component Test Edition Segue
    Purifyplus IBM rational http://www.ibm.com/cn
    Rational Test Realtime IBM rational http://www.ibm.com/cn
    junit 开源
    cactus 开源
    Hansel 开源
    TestNG 开源
    StrutsTestCase 开源
    JFCUnit 开源
    Httpunit 开源
    Dunit 开源
    cppunit 开源 http://sourceforge.net/projects/cppunit
    Nunit 开源
    Xunit 开源
    JTR 开源
    MallocDebug Linux平台工具
    Valgrind Linux平台工具
    Kcachegrind Linux平台工具
    dmalloc Linux平台工具
    ElectricFence Linux平台工具
    LeakTracer Linux平台工具
    memprof Linux平台工具
    ccmalloc Linux平台工具
    mprof Linux平台工具
    yamd Linux平台工具
    njamd Linux平台工具
    mpatrol Linux平台工具
    嵌入式测试工具 VcTester ezTester http://www.eztester.com
    codetest Metrowerks
    Cantata/cantana++ IPL
    IceMaster Reflex Technology
    System test Reflex Technology
    scorecast DDC-I
    Testquest Testquest
    UniText ATTOL
    vectorcast Vector software
    testrunner Qronus
    Logiscope Telelogic http://www.telelogic.com.cn
    测试管理工具 TestDirector(QualityCenter) Mercury
    QADirector Compuware
    certify Worksoft
    Product manager Aimware
    SilkCentral Test Manager Segue
    Doors Telelogic http://www.telelogic.com.cn
    e-manager Empirix
    testmanager IBM Rational http://www.ibm.com/cn
    TestView Manager RadView
    Professional T-Plan
    缺陷管理工具 TestDirector(QualityCenter) Mercury
    ClearQuest IBM Rational http://www.ibm.com/cn
    TrackRecord Compuware
    TestTrack pro Seapine
    TrueTrack McCabe
    Devtrack Techexcel
    Notes IBM Lotus
    SilkCentral Issue Manager Segue
    PVCS Tracker Merant
    AR System Remedy
    URTrack LealSoft
    Butterfly Hansky
    Bugzilla 开源
    Mantis 开源
    JIRA 开源
    BugFree 开源
    配置管理工具 ClearCase IBM Rational http://www.ibm.com/cn
    PVCS Version Manager Merant
    VCS Diamond
    StarTeam Borland
    Perforce Perforce
    TRUEchange McCabe
    SYNERGY CM  Telelogic http://www.telelogic.com.cn
    VSS Microsoft
    Firefly Hansky
    CVS Subversion
    SCCS RCS
    CCC/Harvest Computer Associates

  • WinRunner学习1

    hjjlearning 发布于 2007-04-29 17:48:11

    1,report_msg  :  prints a user-defined string  expression to the test run report
    2,   pause  :     The pause function stops the test run and displays a string expression in a message box on the screen
      report_Msg和pause是在Win下显示的信息,在UNIX下是printf

    3,   radio_button :  控制按扭属性是ON还是OFF,如:
    set_window ("Flight Reservation", 3);
    button_set ("{class: radio_button, MSW_class: Button, label: Business}", ON);
    4,    return[expression]  : 返回值
    5,脚本格式 :
     Test Header :  
     ---------> Test Name
     ---------> Subject
     ---------> Test Creator
     ---------> Date of creation/Date of revision
     ---------> Purpose of the test
     正式脚本
    6,static const <CONST_NAME> = <const_value>;放在脚本最前面
    7,[static/public] <variable_name> = [<variable_value>];静态和公共变量
    8, 三种判断方式
     ------->if (win_exists ("Window_Name") == 0) {
      set_window ("Window_Name");
     --------> if (!win_exists ("Window_Name")) {
       set_window ("Window_Name");
     ---------> if (win_exists ("Window_Name") == E_OK) {
        set_window ("Window_Name");
    9,自己创建错误提示代码的协定
     -------->Error codes should be in capital letters.必须为大写字母
     -------->Error codes should begin with the letter “E” followed by an underscore   (for example, E_MY_ERROR).
      -------->Error code numbers should include a dash “-” followed by a five digit   value (for example, -31001).
     -------->Error codes should be defined as public in a library or initialization test   or example, public const E_MY_ERROR = -31001).
    10, GUI_Load和GUI_Unload
     GUI_Load(file_name):   加载GUI的MAP文件,加载的是全路径
     GUI_unload( ): 释放GUI文件
     如:
    # This loads the GUI file

    GUI_load ("E:\\file1.gui");
    GUI_list_map_buffers(out_file, out_buffer);

    # The out_file contain the loaded gui file file1.gui.

    GUI_unload (file1.gui);

    # This unloads the GUI file

    GUI_list_map_buffers(out_file, out_buffer);
    # Now the out_file array does not contain file1.

    11,tl_step  :  可以输出一些测试的信息
    12,   Function Header         
    The function header is placed above a user defined function. Like the Test
    Header, the function header is enclosed by the "#" symbol and stores
    information about the function:
    >Function Name
    >Descrīption or purpose of the function
    >Input parameters
    >Output parameters
    >Return Values

    For example:
    ################################################################
    # FUNCTION: get_flight_from_table
    # PURPOSE: This function is static only to this file. It selects a flight from the
    # flight table using a given flight number. Also uses split() function to access the
    # flight number from the table.
    #
    # INPUT PARAMS: flight_num   The flight number to be selected.
    # OUTPUT PARAMS:   none
    # RETURN VALUES: Standard return values.
    ###############################################################
    static function get_flight_from_table (in flight_num){...
    13, TSL includes four types of functions:
    >Context Sensitive functions perform specific tasks on GUI objects, such as
    clicking a button or selecting an item from a list. Function names, such as
    button_press and list_select_item, reflect the function’s purpose.
    >Analog functions depict mouse clicks, keyboard input, and the exact
    coordinates traveled by the mouse.
    >tandard functions perform general purpose programming tasks, such as
    sending messages to a report or performing calculations.
    >Customization functions allow you to adapt WinRunner to your testing
    environment.

  • winrunner使用小技巧[转]

    hjjlearning 发布于 2007-04-28 18:03:19

    winrunner使用小技巧

    一、通配符
    ![内容].* (空格)
    如: !Form.* ,表示为“Form”+任何字符串
    !.* Form,表示为任何字符串+“Form”

    二、文件路径
    \\
    TSL 语言中,文件路径要用“\\”表示


    三、控件识别问题
      有时录制脚本时发现有的控件识别不了(比如WEB页面中的标准控件识别不了),
    可能由以下情况造成:
    1. 启动WinRunner时没有加载相应的Addin;
    2. WinRunner在应用程序之后启动;

    3.可用虚拟控件

    四、建立数据库检查点
    有的人发现建立数据库检查点时不能建立新的查询,觉得很奇怪,这是因为系统中没有安装Microsoft Query 的缘故。 Office 2003 中有Microsoft Query的安装,不过缺省是不安装Microsoft Query的,只要运行Office 2003 的安装程序,在更改安装中将Microsoft Query设为从本机运行,确定安装即可。


    五、自动加载GUI Map文件

    static test_Path = getvar("testname"); # 得到测试用例的路径
    static guifile_path = test_Path & "\\GUI_File.gui";
    # GUI Map文件名,建议将GUI Map文件保存在测试脚本的目录中,如果不是,
    将这里改为相应的绝对路径或相对路径

    GUI_unload_all(); # 清空已经加载的GUI Map
    GUI_load(guifile_path); # 加载GUI Map文件

    report_msg(test_Path); # 报告路径,调试脚本时用,正式执行可以不要

    WinRunner是一个黑盒测试工具,可以启动任何程序,模拟所有的键盘和鼠标的输入,检查输出的数据。一般来说,测试一个软件可以分为几个步骤:启动程序、输入数据(键盘和鼠标操作)、检查输出,WinRunner可以实现这些操作,做到自动化执行。


    一般使用方法
    1、启动WinRunner后,会自动弹出“Add-In Manager”窗口,一般不需要选择,直接按“OK”就可以了。
    2、“主菜单-File-New”,创建新的项目
    3、“主菜单-Create-Record - Context Sensitive”,开始录制测试过程
    4、运行被测程序,输入数据,测试各种功能
    5、“主菜单-Create-Stop Recording”,结束录制
    6、重新运行录制好的流程,注意起始环境与录制前一致
    7、流程能正确运行后,设置断点,让流程运行到适当的地方插入检查输出的语句
    8、“主菜单-Create-GUI CheckPoint”可插入检查窗口对象属性的语句
    9、“主菜单-Create-Bitmap CheckPoint”可检查对象的整个图象是否正确
    10、“主菜单-Create-Database CheckPoint”可检查数据库的数据是否正确
    11、“主菜单-Create-Get Text”可获取对象中某个位置上的字符串(用From Screen Area可以获得定位数据),之后可进行比较或赋值到其它地方
    12、可以用“report_msg”函数输出测试结果,“&”是连接符
    13、让流程完全自动执行,不在遇到错误时中止,可以在“主菜单-Setting-General Options”中配置“Break when verification fails”


    高级使用方法
    1、“主菜单-Create-Record - Analog”,可以完全模拟鼠标的运动,例如不按键时鼠标的移动。
    2、可以用function自定义函数,注意要用“auto”在函数开始的地方定义变量
    3、可以用call调用其它流程,流程中传递参数,可以在被调用流程“主菜单-File-Test Properties”里面设置


    注意事项:
    1、WebTest的流程只是重现键盘和鼠标的操作,不会等待被测程序产生结果才进行后面的操作。如果被测程序运行缓慢,可能会造成不同步,这时可以用“wait”函数和“web_sync”函数。
    2、WinRunner7.01的WebTest插件不支持IE6,支持win2000自带的IE5
    3、如果函数中的语句语法有问题,流程执行的顺序将难以预料

我的栏目

数据统计

  • 访问量: 16742
  • 日志数: 9
  • 建立时间: 2007-02-02
  • 更新时间: 2007-10-22

RSS订阅

Open Toolbar