发布新日志

  • How to use assertEquals(casper js )?

    2014-11-07 15:39:49

    Sample
     
    casper.wait(6000, function() {
        casper.test.comment('click on settings 2');
        casper.echo(this.getHTML('p.item-time-viewed'));
        casper.echo(casper.fetchText('p.item-time-viewed'));
        casper.echo(casper.fetchText('p#setting-LegalAspects-UBSewmBasicConditionsText'));
        casper.log('Verify date formate for UBS e-WM');
        casper.test.assertEquals(casper.fetchText('p#setting-LegalAspects-UBSewmBasicConditionsText'),'  UBS e-WM Basic Conditions (Nov 2014)');
        casper.log('Verify date formate for Accepted');
        casper.test.assertEquals(this.getHTML('p.item-time-viewed'), ' Accepted: 01 Nov 2014 22:15:06');
  • How to find document for casperjs

    2014-11-05 18:02:04

    http://casperjs.readthedocs.org/en/latest/installation.html  

    Step1 based on above link to install the tool 
    Step2: 



  • CasperJS 轻量级测试自动化

    2014-11-05 17:59:08

    Sample code 


    01.js file 
    //var url='http://localhost:8080/F81_EwmFrontendWebClient';
    var url = 'http://localhost:8080/F81_EwmFrontendWeb-DEMO/#/';
    var username='DEMO1';




    loginModule = require("login");
    //casper.options.logLevel = 'debug'; //60 seconds for each step to complete it self.
    // casper.options.verbose = true;

    casper.test.begin('test goto myWealth page', 1, function suite(test) {

    casper.start(url, function() {


    this.echo(url);
    this.echo(this.getTitle());
            this.test.assertTitle('UBS Beta');

    loginModule.doLogin(username);

    // your test code beign
    loginModule.doNavTo(username,'myWealth');


    });

    })

    casper.run(function() {
    this.test.done(); // I must be called once all the async stuff has been executed
    this.test.renderResults(true, 0, 'log-02.xml');

    });

    common function 
    login.js file
    var require = patchRequire(require);

    function doLogin(username) {


        console.log(username);

        casper.then(function() {
            console.log('begin to login as user :' + username);
            casper.waitForSelector('input[name="loginID"]', function() {

                casper.test.comment('do login');


                this.sendKeys('input[name="loginID"]', username);

                this.capture('screenshots/' + username + '/01-login.png', {
                    top: 0,
                    left: 0,
                    width: 1024,
                    height: 768
                });

                this.click('button#viewLogin-loginButton');


            });
        });

        casper.wait(1000, function() {


            if (casper.exists('p#view2faLogin-insutruction')) { //DEMO USER SKIP THIS


                casper.waitForSelector('p#view2faLogin-insutruction', function() {

                    casper.test.comment('do faLogin access card');


                    this.echo(this.getHTML('p#view2faLogin-insutruction'));
                    this.sendKeys('input#view2faLogin-accessCode1', '12');
                    this.sendKeys('input#view2faLogin-accessCode2', '34');
                    this.sendKeys('input#view2faLogin-accessCode3', '56');
                    this.sendKeys('input#view2faLogin-accessCode4', '78');

                    this.capture('screenshots/' + username + '/02-acesss-card.png', {
                        top: 0,
                        left: 0,
                        width: 1024,
                        height: 768
                    });


                    this.click('button#view2faLogin-clickLogin');


                });


            }



        });

        casper.wait(1000, function() {



            //this.echo(this.getHTML('div#elag_content_zone'));


            this.capture('screenshots/' + username + '/03-agrrentment.png', {
                top: 0,
                left: 0,
                width: 1024,
                height: 768
            });


            this.click('button#ElagButton-accept');
            casper.test.comment('do accept agrrentment');



        });

        casper.wait(10000, function() {


            this.echo(this.getCurrentUrl());


            if (casper.visible('button.buttonupdate')) {

                this.capture('screenshots/' + username + '/05-homepage-update.png', {
                    top: 0,
                    left: 0,
                    width: 1024,
                    height: 768
                })

                this.click('button.buttonupdate');
                casper.test.comment('do close update');


            }
            if (casper.exists('label#skipVirtualTour')) {

                this.capture('screenshots/' + username + '/05-1-VirtualTour.png', {
                    top: 0,
                    left: 0,
                    width: 1024,
                    height: 768
                })

                this.click('label#skipVirtualTour');
                casper.test.comment('do close VirtualTour');


            }



        });

        casper.wait(1000, function() {


            if (casper.visible('div.demo-window')) {

                this.capture('screenshots/' + username + '/05-2-homepage-with-tips.png', {
                    top: 0,
                    left: 0,
                    width: 1024,
                    height: 768
                })

                this.click('div.demo-close-button');
                casper.test.comment('do close homepage tips');


            }



        })

        casper.wait(10000, function() {

            this.capture('screenshots/' + username + '/05-homepage.png', {
                top: 0,
                left: 0,
                width: 1024,
                height: 768
            });


        })
    }


    exports.doLogin = doLogin;


    function doNavTo(username, pageID) {
        var nav_id;

        switch (pageID) {
            case 'settings':

                nav_id = 'settings';

                break;
            case 'myWealth':

                nav_id = 'myWealth';

                break;
            case 'help':

                nav_id = 'help';

                break;

        }

        casper.wait(1000, function() {
            casper.test.comment('nav  to pageID:' + pageID);
            this.click('span#menuIcon');

        });



        casper.waitForSelector('common-mainmenu-item#' + nav_id, function() {


            this.click('common-mainmenu-item#' + nav_id + '>li');


            // this.capture('screenshots/' + username + '/06-homepage-submenu.png', {
            //     top: 0,
            //     left: 0,
            //     width: 1024,
            //     height: 768
            // });



        })


        casper.wait(6000, function() {

            this.echo(this.getCurrentUrl());


            this.capture('screenshots/' + username + '/' + nav_id + '.png', {
                top: 0,
                left: 0,
                width: 1024,
                height: 768
            });


        })


        //body end

    }

    exports.doNavTo = doNavTo;

  • Test Automation Frameworks-什么是自动化测试框架

    2014-04-11 14:51:09

    转载(自己翻译)

    What is a Framework ?

    Instead of providing a bookish definition of a framework, lets consider an example.

    I am sure you have attended a seminar / lecture / conference where the participants was asked to observe the following  guidelines -

     

    •    Participants should occupy their seat 5 minutes before start of lecture
    •    Bring along a notebook and pen for note taking.
    •    Read the abstract so you have an idea of what the presentation will be about.
    •   Mobile Phones should be set on silent
    •   Use the exit gates at opposite end to the speaker should you require to leave in middle of the lecture.
    •   Questions will be taken at the end of the session

     

    Do you think you can conduct a seminar WITHOUT observing these guidelines????

    The answer is a big YES! Certainly you can conduct a seminar / lecture / conference / demonstration without above guidelines (in fact some of us will not follow them even though there are laid  ... wink)

     

    But if the guidelines are followed it will result in beneficial outcome like reduced audience distraction during lecture and increased participant retention and understanding of the subject matter.

    Based on above, a Framework can be defined as a set of guidelines which when followed produce beneficial results.

    Now what is a TEST Automation Framework ?

    什么是测试框架

    A set of guidelines like coding standards , test-data handling , object repository treatment  etc... which when followed during automation scripting produce beneficial outcomes like increase code re-usage ,  higher portability  , reduced script. maintenance cost  etc. Mind you these are just guidelines and not rules; they are not mandatory and you can still script. without following the guidelines. But you will miss out on the advantages of having a Framework.

    测试框架是一系列的准则,就像编码规则,测试数据处理方法,对象库管理方法 等等,如果我们遵循这些准则,将会带来很多好处,就像 增加代码的复用率,可移植性,减少代码的维护成本等等。这些准则都是一些参考并不是一定要遵守的规则,你也可以不遵守这些规则去写代码,框架带来的好处你就体会不到了。

    What are the various Automation Frameworks available?

    1) Linear Scripting

    线性脚本
    2)The Test Library Architecture Framework.

    测试库体系结构框架
    3)The Data-Driven Testing Framework.

    数据驱动
    4)The Keyword-Driven or Table-Driven Testing Framework.

    关键字驱动
    5)The Hybrid Test Automation Framework.

    混合驱动

    Lets  look at them in detail -

    1) Linear Scripting - Record & Playback

    It is the simplest of all Frameworks and also know as "Record & Playback".In this Framework , Tester manually records each step ( Navigation and User Inputs), Inserts Checkpoints ( Validation Steps) in the first round . He then , Plays back the recorded script. in the subsequent rounds.

    这是最简单录制回放的框架,测试人员手动 录制每个步骤,在第一轮的是就插入检查点,然后在第二轮的时候回放录制的脚本。

    Ex :  Consider logging into Flight Reservation Application and checking wether the application has loaded on successful log-on. Here , the tester will simply record the steps and add validation steps.

    eg.

    考虑登陆飞机定票系统,验证系统是不是登陆成功,测试人员简单的录制然后回放校验。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    SystemUtil.Run "flight4a.exe","","","open"
     
        Dialog("Login").WinEdit("Agent Name:").Set "Guru99"
     
        Dialog("Login").WinEdit("Password:").Set "Mercury"
     
        Dialog("Login").WinButton("OK").Click
     
        'Check Flight Reservation Window has loaded after successful log-on
     
        Window("Flight Reservation").Check CheckPoint("Flight Reservation")

    Advantages

    优点

    • Fastest way to generate script.

    很快就能生成脚本。

    • Automation expertise not required

    不需要自动化测试的经验。

    • Easiest way to learn the features of the Testing Tool

    最简单的方法去学习测试工具的各种功能。

    Disadvantages

    缺点

    • Little reuse of scripts

    代码重用率低

    • Test data is hard coded into the script.

    测试数据直接写死在代码里。

    • Maintenance Nightmare

    维护起来困难

    2)The Test Library Architecture Framework.

    测试库体系结构框架。

    It is also know as "Structured Scripting" or "Functional Decomposition".

    有时候也叫结构化脚本或者功能分解

    In this Framework , test scripts are initially recorded by "Record & Playback" method. Later, common tasks inside the scripts are identified and grouped into Functions. These Functions are called by main test script. called Driver in different ways to create test cases.

    在这种框架下, 测试脚本开始的时候都是通过录制回放生成的,然后,脚本中常用的功能被封装在不同的function 函数中,这些function都可以在脚本中调用。在测试用例中叫驱动

    Ex:Using the same example as above, the function for logging in to Flight Reservation will look like .

     

          Function Login()

    1
    2
    3
    4
    5
    6
    7
    8
    9
    SystemUtil.Run "flight4a.exe","","","open"
     
    Dialog("Login").WinEdit("Agent Name:").Set "Guru99"
     
    Dialog("Login").WinEdit("Password:").Set "Mercury"
     
    Dialog("Login").WinButton("OK").Click
     
    End Function

    Now, you will call this function in the main script. as follows

        'Driver Script

    1
    2
    3
    4
    5
    6
    7
    Call Login()
     
    ---------------------------
     
    Other Function calls / Test Steps.
     
    ---------------------------

    Advantages

    优点

    • Higher level of code reuse is achieved in Structured Scripting as compared to "Record & Playback"

    与录制回放功能对比起来,代码复用率高

    • The automation scripts are less costly to develop due to higher code re-use
    • Easier Script. Maintenance

    代码维护起来更容易

    Disadvantages

    缺点

    • Technical expertise is necessary to write  Scripts using Test Library Framework.
    • More time is needed to plan and prepare test scripts.

    需要更多时间去准备测试脚本

    • Test Data is hard coded within the scripts

    测试数据是在代码中写死的

    3)The Data-Driven Testing Framework.

    数据驱动框架

    In this Framework , while Test case logic resides in Test Scripts, the Test Data is separated and kept outside the Test Scripts.Test Data is read from the external files (Excel Files, Text Files, CSV Files, ODBC Sources, DAO Objects, ADO Objects) and are loaded into the variables inside the Test Script. Variables are used both for Input values and for Verification values. Test Scripts themselves are prepared either using Linear Scripting  or Test Library Framework.

    在这个框架下,测试用例是嵌套在测试脚本中的,但是测试数据是独立于脚本而保存在别的地方,测试数据保存在外部文件中(Excel Files, Text Files, CSV Files, ODBC Sources, DAO Objects, ADO Objects),在运行过程中加载进脚本的, 变量在输入值和校验值中都需要用的, 测试脚本是线性框架或者测试对象库框架。

    Ex: Developing the Flight Reservation Login script. using this method will involve two steps.

    在飞机顶票系统中用这个方法有两步:

    Step 1) Create a Test - Data file which could be Excel , CSV , or any other database source.

    第一步: 创建测试数据

    AgentName

    Password

    Jimmy

    Mercury

    Tina

    MERCURY

    Bill

    MerCURY

    Step 2) Develop Test Script. and make references to your Test- Data source.

    创建测试脚本

          SystemUtil.Run "flight4a.exe","","","open"

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    Dialog("Login").WinEdit("Agent Name:").Set DataTable("AgentName", dtGlobalSheet)
     
    Dialog("Login").WinEdit("Password:").Set DataTable("Password", dtGlobalSheet)
     
    Dialog("Login").WinButton("OK").Click
     
    'Check Flight Reservation Window has loaded
     
    Window("Flight Reservation").Check CheckPoint("Flight Reservation")
     
    **Note "dtGlobalSheet" is the default excel sheet provided by QTP.

    Advantages

    • Changes to the Test Scripts do not affect the Test Data

    修改测试脚本不会影响测试数据

    • Test Cases can be executed with multiple Sets of Data

    测试用来可以在多组测试数据中执行

    • A Variety of Test Scenarios can be executed by just varying the Test Data in the External Data File

    改变外部测试数据来实现不同测试场景的测试

    DisAdvantages

    缺点

    • More time is needed to plan and prepare both Test Scripts and Test Data

    需要更多的时间去计划和准备测试脚本和测试数据。

    4)The Keyword-Driven

    关键字驱动

    or Table-Driven Testing Framework.

    The Keyword-Driven or Table-Driven framework requires the development of data tables and keywords, independent of the test automation tool used to execute them . Tests can be designed with or without the Application. In a keyword-driven test, the functionality of the application-under-test is documented in a table as well as in step-by-step instructions for each test.

    There are 3 basis components of a Keyword Driven Framework viz. Keyword , Application Map , Component Function.

    What is a Keyword ?

    Keyword is an Action that can be performed on a GUI Component. Ex . For GUI Component Textbox some Keywords ( Action) would be InputText, VerifyValue, VerifyProperty and so on.

    What is Application Map?

    An Application Map Provides Named References for GUI Components. Application Maps are nothing but "Object Repositry"

    What is Component Function?

    Component Functions are those functions that actively manipulate or interrogate GUI component. An example of a function would be click on web button with all error handling , enter data in a Web Edit with all error handling. Component functions could be application dependent or independent.

    Ex: To understand Keyword View lets take the same example. It invovles 2 steps

    Step 1: Creating Data Table (Different from Test-Data Table created in Data Driven Framework). This Data Table contains Action to be performed on GUI Objects and correspoding arguments if any. Each row respresents one Test Step.

    Object

    (Application MAP)

    Action

    (KEYWORDS)

    Argument

    WinEdit(Agent Name)

    Set

    Guru99

    WinEdit(Password)

    Set

    Mercury

    WinButton(OK)

    Click

     

    Window(Flight Reservation)

    Verify

    Exists

    Step 2: Writing Code in the form. of Component Functions.

    Once you've created your data table(s), you simply write a program or a set of scripts that reads in each step, executes the step based on the keyword contained the Action field, performs error checking, and logs any relevant information. This program or set of scripts would look similar to the pseudo code below:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    Function main()
     
    {
     
               Call ConnectTable(Name of the Table) {   //Calling Function for connecting to the table.
     
                       while (Call TableParser() != -1)  //Calling function for Parsing and extracting values from the table.
     
                      {
     
                          Pass values to appropriate  COMPONENT functions. Like Set(Object Name , Argument) ex. Set( Agent Name , Guru99).
     
                      }
     
               }   
     
                     Call CloseConnection()   //Function for Closing connection after all the operation has been performed.
     
     }   //End of main

    Thats all to Keyword Driven Framework.

    The advantage of Keyword Driven Framework is that the Keywords are re-usable. To understand this consider  you want to verify login operation for a Website say YAHOO MAIL.  The table will look like this -

    Object

    (APPLICATION MAP)

       Action

    (KEYWORD)

          Argument

    WebEdit(UserName)

    Set

    abc@yahoo.com This email address is being protected from spambots. You need JavaScript. enabled to view it.

    WebEdit(Password)

    Set

    xxxxx

    WebButton(OK)

    Click

     

    Window(Yahoo Mail)

    Verify

    Loads

    If you observe in this case the Keywords Set , Click , Verify remain the same for which corresponding component functions are already developed. All you need to do is change the Application Mapping (Object Repository) from earlier Flight Reservation to Yahoo Mail , with change in argument values and the same script. will work!

    Advantages

    • Provides high code re-usability
    • Test Tool Independent
    • Independent of Application Under Test, same script. works for AUT (with some limitations)
    • Tests can be designed with or without AUT

    Disadvantages

    • Initial investment being pretty high, the benefits of this can only be realized if the application is considerably big and the test scripts are to be maintained for quite a few years.
    • High Automation expertise is required to create the Keyword Driven Framework.

    NOTE : Even though QTP advertises itself as KeyWord Driven Framework, you can not achieve complete test tool and application idependence using QTP.

    5)The Hybrid Test Automation Framework.

    As the name suggests this framework is the combination of one or more frameworks discussed above pulling from their strengths and trying to mitigate their weaknesses. This hybrid test automation framework is what most frameworks evolve into over time and multiple projects. Maximum industry uses Keyword Framework in combination of Function decomposition method.

    PS:  Other Frameworks worth a mention are

    1) Test Modularity Framework 

    In this framework common task in test script. are grouped together as Modules.

    Ex:Using Actions in QTP use can create a Modualr Scripts

       'Sample Script. for Login

    1
    2
    3
    4
    5
    6
    7
    8
    9
    SystemUtil.Run "flight4a.exe","","","open"
     
    Dialog("Login").WinEdit("Agent Name:").Set "Guru99"
     
    Dialog("Login").WinEdit("Password:").Set "Mercury"
     
    Dialog("Login").WinButton("OK").Click
     
    'End of Script

    Now you can call this Action in the main script. as follows - 

       RunAction ("Login[Argument]", oneIteration)

    2) Business Process Testing (BPT) -

    This frameworks , breaks up large Business Processes into Components  which can re-used multiple times in the  same or different test scripts. For example , the Business Process of Booking a flight is split into components like Login , Finding Flights , Booking , Payment & Logout which can be re-used in the same  Business process or different processes. Also, BPT facilitates closer coordination amongst SME's and Automation Engineers

    Usefull links for keyword driven

    http://www.automationrepository.com/2012/11/desigining-keyword-driven-framework-mapped-at-functional-level-part-2/

  • Just Unix基础重温之cat

    2014-02-18 16:40:25

    Just Unix基础重温之cat

    博客分类:
    Just Unix & Linux
    Unix
    cat 的用途很多,文件编辑的时候也常常使用。
    1. 查看文件
           $ cat daily_log
    just for myself
    I just love u
    end
    (行数较多的时候可以使用more或less 分屏查看)
     
    2. 拼接文件
      
    $ cal 1 2011 > 1
    $ cal 2 2011 > 2
    $ cat 1 2 > calender
     

    (把2个月的日历输出到calender里面) 
    $ cat calendar
    (查看calender文件)
         January 2011
    Su Mo Tu We Th Fr Sa
                       1
     2  3  4  5  6  7  8
     9 10 11 12 13 14 15
    16 17 18 19 20 21 22
    23 24 25 26 27 28 29
    30 31
        February 2011
    Su Mo Tu We Th Fr Sa
           1  2  3  4  5
     6  7  8  9 10 11 12
    13 14 15 16 17 18 19
    20 21 22 23 24 25 26
    27 28
     
    ”>“和”>>“的区别:
    > :是重定向符,会覆盖旧的文件以后再写入新的内容
    >> : 是追加符,添加在文件尾部
     
    3. 常用通道
      -n 对显示的所有行进行编号
    $ cat daily_log
    1 just for myself
    2 I just love u
    3 end
     
    -s 合并空白行
  • Oracle 语法之 OVER (PARTITION BY ..) 及开窗函数 转载

    2013-12-09 14:11:37

    Oracle 语法之 OVER (PARTITION BY ..) 及开窗函数 转载
     
    oracle的分析函数over 及开窗函数
    一:分析函数over
    Oracle从8.1.6开始提供分析函数,分析函数用于计算基于组的某种聚合值,它和聚合函数的不同之处是
    对于每个组返回多行,而聚合函数对于每个组只返回一行。
    下面通过几个例子来说明其应用。                                       
    1:统计某商店的营业额。        
         date       sale
         1           20
         2           15
         3           14
         4           18
         5           30
        规则:按天统计:每天都统计前面几天的总额
        得到的结果:
        DATE   SALE       SUM
        ----- -------- ------
        1      20        20           --1天           
        2      15        35           --1天+2天           
        3      14        49           --1天+2天+3天           
        4      18        67            .          
        5      30        97            .
         
    2:统计各班成绩第一名的同学信息
        NAME   CLASS S                         
        ----- ----- ----------------------
        fda    1      80                     
        ffd    1      78                     
        dss    1      95                     
        cfe    2      74                     
        gds    2      92                     
        gf     3      99                     
        ddd    3      99                     
        adf    3      45                     
        asdf   3      55                     
        3dd    3      78              
       
        通过:   
        --
        select * from                                                                       
        (                                                                            
        select name,class,s,rank()over(partition by class order by s desc) mm from t2
        )                                                                            
        where mm=1
        --
        得到结果:
        NAME   CLASS S                       MM                                                                                        
        ----- ----- ---------------------- ----------------------
        dss    1      95                      1                      
        gds    2      92                      1                      
        gf     3      99                      1                      
        ddd    3      99                      1          
       
        注意:
        1.在求第一名成绩的时候,不能用row_number(),因为如果同班有两个并列第一,row_number()只返回一个结果          
        2.rank()和dense_rank()的区别是:
          --rank()是跳跃排序,有两个第二名时接下来就是第四名
          --dense_rank()l是连续排序,有两个第二名时仍然跟着第三名
         
         
    3.分类统计 (并显示信息)
        A   B   C                      
        -- -- ----------------------
        m   a   2                      
        n   a   3                      
        m   a   2                      
        n   b   2                      
        n   b   1                      
        x   b   3                      
        x   b   2                      
        x   b   4                      
        h   b   3
       select a,c,sum(c)over(partition by a) from t2                
       得到结果:
       A   B   C        SUM(C)OVER(PARTITIONBYA)      
       -- -- ------- ------------------------
       h   b   3        3                        
       m   a   2        4                        
       m   a   2        4                        
       n   a   3        6                        
       n   b   2        6                        
       n   b   1        6                        
       x   b   3        9                        
       x   b   2        9                        
       x   b   4        9                        
      
       如果用sum,group by 则只能得到
       A   SUM(C)                            
       -- ----------------------
       h   3                      
       m   4                      
       n   6                      
       x   9                      
       无法得到B列值       
      
    =====

    select * from test

    数据:
    A B C
    1 1 1
    1 2 2
    1 3 3
    2 2 5
    3 4 6


    ---将B栏位值相同的对应的C 栏位值加总
    select a,b,c, SUM(C) OVER (PARTITION BY B) C_Sum
    from test

    A B C C_SUM
    1 1 1 1
    1 2 2 7
    2 2 5 7
    1 3 3 3
    3 4 6 6



    ---如果不需要已某个栏位的值分割,那就要用 null

    eg: 就是将C的栏位值summary 放在每行后面

    select a,b,c, SUM(C) OVER (PARTITION BY null) C_Sum
    from test

    A B C C_SUM
    1 1 1 17
    1 2 2 17
    1 3 3 17
    2 2 5 17
    3 4 6 17

     

    求个人工资占部门工资的百分比

    SQL> select * from salary;

    NAME DEPT SAL
    ---------- ---- -----
    a 10 2000
    b 10 3000
    c 10 5000
    d 20 4000

    SQL> select name,dept,sal,sal*100/sum(sal) over(partition by dept) percent from salary;

    NAME DEPT SAL PERCENT
    ---------- ---- ----- ----------
    a 10 2000 20
    b 10 3000 30
    c 10 5000 50
    d 20 4000 100

    二:开窗函数           
          开窗函数指定了分析函数工作的数据窗口大小,这个数据窗口大小可能会随着行的变化而变化,举例如下:
    1:     
       over(order by salary) 按照salary排序进行累计,order by是个默认的开窗函数
       over(partition by deptno)按照部门分区
    2:
      over(order by salary range between 5 preceding and 5 following)
       每行对应的数据窗口是之前行幅度值不超过5,之后行幅度值不超过5
       例如:对于以下列
         aa
         1
         2
         2
         2
         3
         4
         5
         6
         7
         9
       
       sum(aa)over(order by aa range between 2 preceding and 2 following)
       得出的结果是
                AA                       SUM
                ---------------------- -------------------------------------------------------
                1                       10                                                      
                2                       14                                                      
                2                       14                                                      
                2                       14                                                      
                3                       18                                                      
                4                       18                                                      
                5                       22                                                      
                6                       18                                                                
                7                       22                                                                
                9                       9                                                                 
                 
       就是说,对于aa=5的一行 ,sum为   5-1<=aa<=5+2 的和
       对于aa=2来说 ,sum=1+2+2+2+3+4=14     ;
       又如 对于aa=9 ,9-1<=aa<=9+2 只有9一个数,所以sum=9    ;
                  
    3:其它:
         over(order by salary rows between 2 preceding and 4 following)
              每行对应的数据窗口是之前2行,之后4行
    4:下面三条语句等效:           
         over(order by salary rows between unbounded preceding and unbounded following)
              每行对应的数据窗口是从第一行到最后一行,等效:
         over(order by salary range between unbounded preceding and unbounded following)
               等效
         over(partition by null)
  • 面对测试外包我们在走向何方 (转)

    2013-11-28 09:29:44

      面对测试外包我们在走向何方
      现在我们的测试团队越来越多都采取了外包方式,而且大家也绝大外包测试团队可以有效的控制质量并降低成本,但是实际情况真的是这样么?下面的数据估计大家身在其中也深有体会把!
      CIO们将全部测试和开发项目的48%外包,但是几乎有四分之一的项目无法交付,这给31%的工作带来了威胁
      <!--[if !vml]-->点击图片可在新窗口打开<!--[endif]-->
      根据最新的全球调查,57%的IT领导者表示其部分外包项目无法管理、处境艰难、像是噩梦一般,或者彻底失败
      英国纽伯里2013年11月12日
      几乎一半 (48%) 的测试和开发项目都采用外包形式,CIO 们预计在未来两年的时间里还将增长大约 14.5%。  然而,31% 的外包项目遇到了服务级别或时间问题,23% 无法按最终要求交付,因此威胁到了 31% 的 CIO 的工作。  此信息来源于 Vanson Bourne 受 Micro Focus 公司的 Borland (伦敦证券交易所代码:MCRO.L)委托所做的一项独立的全球调查研究。
      在接受调查的来自全球 9 个国家/地区的 590 位 CIO 和 IT 总监中,超过半数 (57%) 表示他们的部分外包测试和开发项目无法管理、处境艰难、像噩梦一般,或者彻底失败。  大部分受访者 (55%) 认为项目过程中过多地需求更改是项目超支和延期,或无法按最终需求交付的主要原因。  47% 的公司都有过至少两星期或者更频繁地更改一次外包供应商负责项目的工作规范的经历,这是一个严重的问题。
      要求难题
      IT 领导者就其自身能力及其外包合作伙伴能力勾勒出一副让人伤透脑筋的画面,在开始时准确定义项目需求以及在项目过程中管理变更需求:
      ·         81% 的受访者说,他们无法完全自信地在项目开始时清楚地将项目要求文档化并将其传达给外包供应商
      ·         不到一半的人说他们使用了专门的需求软件工具。  大多数还是依赖像 Excel 这样的电子表格和 Word 格式的书面文档来收集其需求
      ·         只有 37% 的受访者觉得他们在外包合同履行过程中可以很好地管理可变性、多样性和变更
      ·         更少 (27%) 的受访者觉得外包供应商能够自行为各方管理这些变更
      ·         85% 的受访者说他们会收集需求并将其与各利益相关方共享,这增加了复杂性,从而导致项目出现问题或失败的可能性增加
      成本因素
      尽管有清楚的需求,受访者说仍有68%的外包供应商并不期望需求会作为任何项目的前提条件而第一次就正确,只有15%的供应商会在项目开始时实际审核原始需求并提出更改建议。 有趣的是,超过三分之一(37%)的受访者说外包合作伙伴通过变更来推动可盈利性,这可以解释为什么供应商不愿意在项目一开始确定需求。 几乎所有CIO (96%)都确认变更需求会导致意外增加成本,但只有三分之一的CIO觉得这些成本是公平的。
      合作伙伴问题
      当问到在项目过程中关于时间或服务级别问题与外包供应商的关系时,超过一半的CIO (53%)说他们对合作伙伴感到失望。让人吃惊的是,43%的CIO说尽管远远达不到预期,但在使用外包供应商时出现问题也是意料之中的事情,这似乎排除了合作伙伴的责任。因此,只有35%的受访者说在未达到服务级别时他们的外包合作伙伴肯定会按照合同承担财务损失。总体而言,84%的受访者声称外包开发和测试项目已经为他们的企业带来了负面问题,包括延迟提交客户产品(39%)、保护公司IP的能力(29%)和声誉(25%),甚至还包括对公司收入产生了影响(12%)。
      内部影响
      尽管会外包其测试和开发需求,但让人震惊的是,98%的CIO都确认在外包项目最终提交后仍然需要进行某种形式的额外内部工作。
      其他发现
      <!--[if !supportLists]-->·        <!--[endif]-->大多数受访者(52%)都会与3-5家外包供应商合作
      <!--[if !supportLists]-->·        <!--[endif]-->每个平均大小的外包测试和开发项目都需要超过5年(按一人算)的时间
      <!--[if !supportLists]-->·        <!--[endif]-->目前的外包测试和开发项目包括以下应用程序(按项目大小顺序):云应用程序、面向客户的应用程序、大型机应用程序、桌面应用程序、内部业务应用程序和移动应用程序。
      Micro Focus的Borland副总裁Chris Livesey说:“此项调查强调那些相对糟糕的外包结果常常是因为对需求管理和测试规范的过程缺乏投入导致的,这是我们发现当今市场上的一致看法。但是,通过在项目早期阶段进行投入以获得更清楚的需求说明及其关联的测试案例,使最终客户和服务提供商能在合同开始时更准确地预估项目计划、风险和成本,可以大大地改善结果。这种透明度可通过将原则和专门的工具结合使用来比较直接地实现,从而对这些需求和测试案例在项目过程中发生演变时有更强的控制力。有了早期的这一连续可见性,这些合作伙伴关系可以使双方更加有效地开展工作。”
      ###
      编者注
      此项独立调查研究是由 Vanson Bourne 在 2013 年 8 月进行的。  它涵盖了来自以下 9 个国家/地区的 590 位 IT 决策者:英国 (100)、法国 (100)、德国 (100)、美国 (100)、巴西 (100)、澳大利亚 (35)、新西兰 (15)、香港特别行政区 (15) 和新加坡 (25)。 受访者均来自员工人数超过 500 的大型企业,涵盖多个行业部门,并且已经外包测试或开发应用程序。
  • grep命令常用15招 zhuan

    2013-06-19 09:37:09

    首先创建我们练习grep命令时需要用到的demo文件: demo_file

    $ cat demo_file
    THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
    this line is the 1st lower case line in this file.
    This Line Has All Its First Character Of The Word With Upper Case.

    Two lines above this line is empty.
    And this is the last line.

    1.从单个文件中搜索指定的字串

    grep的基础用法是如下例的从指定的文件中搜索特定的字串。

    语法:
    grep "literal_string" filename
    $ grep "this" demo_file
    this line is the 1st lower case line in this file.
    Two lines above this line is empty.
    And this is the last line.

    2. 在多个文件中检索指定的字串

    语法:
    grep "string" FILE_PATTERN
    先拷贝demo_file为demo_file1。grep的结果在符合条件的行前将包括文件名。当文件名包含元字符时,linux shell会将匹配的所有文件作为输入到grep中去。
    $ cp demo_file demo_file1

    $ grep "this" demo_*
    demo_file:this line is the 1st lower case line in this file.
    demo_file:Two lines above this line is empty.
    demo_file:And this is the last line.
    demo_file1:this line is the 1st lower case line in this file.
    demo_file1:Two lines above this line is empty.
    demo_file1:And this is the last line.

    3. 用 grep -i 进行大小写无关的搜索

    语法:
    grep -i "string" FILE


    也是一个基本用法,对搜索的字串忽略大小写,因此下例中匹配“the”, “THE” and “The”。

    $ grep -i "the" demo_file
    THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
    this line is the 1st lower case line in this file.
    This Line Has All Its First Character Of The Word With Upper Case.
    And this is the last line.

    4. 使用用正则表达式

    语法:
    grep "REGEX" filename


    如果你能有效地利用正则表达式,这是个很有用的特点。在下面的例子中,搜索全部以“lines”开始以“empty”结束的字串,如搜索“lines[之间任意字]empty” ,并且忽略大小写。

    $ grep -i "lines.*empty" demo_file
    Two lines above this line is empty.

    正则表达式遵循的几个重复的操作

    • ? 最多匹配一次
    • * 匹配零次或者任意多次
    • + 匹配一次以上
    • {n} 匹配n次
    • {n,} 最少匹配n次
    • {,m} 最多匹配m次
    • {n,m} 匹配n到m次

    5. 用grep -w搜索整个词,而不是词中的部分字串

    使用-w选项搜索一个单词,并且避免搜索到词中的部分字串。

    下例搜索"is"。如果不加-w选项,将显示“is”, “his”, “this” 等所有包含“is”的行。

    $ grep -i "is" demo_file
    THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
    this line is the 1st lower case line in this file.
    This Line Has All Its First Character Of The Word With Upper Case.
    Two lines above this line is empty.
    And this is the last line.


    下例使用了-w选项,请注意结果中不包含 “This Line Has All Its First Character Of The Word With Upper Case”, 虽然 “This”中包含“is”。

    $ grep -iw "is" demo_file
    THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
    this line is the 1st lower case line in this file.
    Two lines above this line is empty.
    And this is the last line.

    6. 使用grep -A, -B and -C显示之前、之后、前后的几行

    当使用grep搜索大文件时,显示匹配行附近的多行数据是一个很有用的功能。


    创建如下文件

    $ cat demo_text
    4. Vim Word Navigation

    You may want to do several navigation in relation to the words, such as:

    * e - go to the end of the current word.
    * E - go to the end of the current WORD.
    * b - go to the previous (before) word.
    * B - go to the previous (before) WORD.
    * w - go to the next word.
    * W - go to the next WORD.

    WORD - WORD consists of a sequence of non-blank characters, separated with white space.
    word - word consists of a sequence of letters, digits and underscores.

    Example to show the difference between WORD and word

    * 192.168.1.1 - single WORD
    * 192.168.1.1 - seven words.

    6.1 显示匹配行之后的N行

    -A

    语法:
    grep -A "string" FILENAME


    下例显示匹配行和之后的3行数据

    $ grep -A 3 -i "example" demo_text
    Example to show the difference between WORD and word

    * 192.168.1.1 - single WORD
    * 192.168.1.1 - seven words.

    6.2显示匹配行之前的N行

    -B

    语法:
    grep -B "string" FILENAME


    下例显示匹配行和之前的2行数据

    $ grep -B 2 "single WORD" demo_text
    Example to show the difference between WORD and word

    * 192.168.1.1 - single WORD

    6.3显示匹配行前后的N行

    -C 显示之前的n行,之后的n行数据.

    $ grep -C 2 "Example" demo_text
    word - word consists of a sequence of letters, digits and underscores.

    Example to show the difference between WORD and word

    * 192.168.1.1 - single WORD

    7.通过GREP_OPTIONS高亮显示搜索的字串

    如果你希望搜索的字串高亮显示在结果中,可以试用以下的办法。

    通过修改GREP_OPTIONS对搜索字串高亮显示。

    $ export GREP_OPTIONS='--color=auto' GREP_COLOR='100;8'

    $ grep this demo_file
    this line is the 1st lower case line in this file.
    Two lines above this line is empty.
    And this is the last line.

    8. 用grep -r递归搜索全部的文件

    如果想查找当前目前以及其子目录的全部文件时,可以使用 -r 选项。如下例

    $ grep -r "ramesh" *

    9. 使用grep -v进行不匹配

    可以使用-v选项显示不匹配搜索字串的行。下例显示demo_text文件中不包含“go”的行

    $ grep -v "go" demo_text
    4. Vim Word Navigation

    You may want to do several navigation in relation to the words, such as:

    WORD - WORD consists of a sequence of non-blank characters, separated with white space.
    word - word consists of a sequence of letters, digits and underscores.

    Example to show the difference between WORD and word

    * 192.168.1.1 - single WORD
    * 192.168.1.1 - seven words.

    10. 显示不匹配全部模式的行

    语法:
    grep -v -e "pattern" -e "pattern"

    创建如下例子文件

    $ cat test-file.txt
    a
    b
    c
    d

    $ grep -v -e "a" -e "b" -e "c" test-file.txt
    d

    11.用grep -c 统计匹配的行数

    语法:
    grep -c "pattern" filename
    $ grep -c "go" demo_text
    6


    统计不匹配的行数

    $ grep -v -c this demo_file
    4

    12. 用grep -l 只显示文件名

    $ grep -l this demo_*
    demo_file
    demo_file1

    13. 只显示匹配的字串

    缺省显示匹配字串的所在行,可以使用-o选项只显示匹配的字串。这项功能当使用正则表达式时比较有用处。

    $ grep -o "is.*line" demo_file
    is line is the 1st lower case line
    is line
    is is the last line

    14. 显示匹配的位置

    语法:
    grep -o -b "pattern" file
    $ cat temp-file.txt
    12345
    12345

    $ grep -o -b "3" temp-file.txt
    0:3
    6:3


    注意: 以上输出显示的不是行内的位置,而是整个文件中的字节byte位置

    15. 用 grep -n 在输出时显示行号

    行号从1开始

    $ grep -n "go" demo_text
    5: * e - go to the end of the current word.
    6: * E - go to the end of the current WORD.
    7: * b - go to the previous (before) word.
    8: * B - go to the previous (before) WORD.
    9: * w - go to the next word.
    10: * W - go to the next WORD.
  • 自动化测试脚本的编写方法

    2011-06-15 10:36:29

    自动化测试项目也像普通的软件开发项目一样,有编码阶段,自动化测试的编码阶段主要是编写测试脚本实现所设计的自动化测试用例。自动化功能测试脚本地开发方法主要有以下几种:1.线性的 2.结构化的 3.共享的 4.数据驱动的 5.关键字驱动的

          线性脚本的编写方法是使用简单的录制回放的方法,测试工程师使用这种方法来自动化地测试系统的流程或某些系统测试用例。它可能包含某些多余的、有时候并不需要的函数脚本。

         结构化脚本编写方法在脚本中使用结构控制。结构控制让测试人员可以控制测试脚本,或测试用例的流程。在脚本中,典型的结构控制是使用“if-else”,“switch”,“for”,“while”等条件状态语句来帮助实现判定、实现某些循环任务、调用其他覆盖普遍功能的函数。

         共享脚本编写方法是把代表应用程序行为的脚本在其他脚本之间共享。这意味着把被测应用程序的公共的、普遍的功能的测试脚本独立出来,其他脚本对其进行调用。这使得某些脚本按照普遍功能划分来标准化、组件化。这种脚本甚至也可以使用在被测系统之外的其它软件应用系统。

          数据驱动脚本编写方法把数据从脚本分离出去,存储在外部的文件中。这样,脚本就只包含编程代码了。这在测试运行时要改变数据的情况下时是需要的。这样,脚本在测试数据改变是不需要修改代码。有时候,测试的期待结果值也可以跟测试输入数据一起存储在数据文件中。 

         关键字驱动脚本编写方法把检查点和执行操作的控制都维护在外部数据文件。因此,测试数据和测试的操作序列控制都是在外部文件中设计好的,除了常规的脚步外,还需要额外的库来翻译数据。关键字驱动脚本编写方法是数据驱动测试方法的扩展。

         总结起来看,对于开发的成本来说,随着脚本编写方法从线性倒关键字驱动的改变而不断地增加;对于维护成本来说,随着脚本编写方法从线性倒关键字驱动的改变而在下降。对于编程技能要求来讲,随着脚本编写方法从线性倒关键字驱动的改变,对一个测试员的变成熟练程度的要求在增加。对于设计和管理的需要来说,随着脚本编写方法从线性倒关键字驱动的改变,设计和管理自动化测试项目的要求在增加。因此,应该合理地选择自动化测试脚本开发方法,在适当的时候,使用适当的脚本开发方法。

  • QTP测试常问问题及答案

    2011-06-10 16:55:40

    塔塔面试questions:

    1.     如何管理对象库

    1Browser只允许出现3种,即主页面(Main),次页面(Sub_O)、第三页(Sub_T),其中主页面Main没有creatontime标记,次页面Sub_Ocreatontime标记值为1,第三页面Sub_TSub_Ocreatontime标记值为2

    2Page页的名称需和页面的Title对应

    3)出现重复的对象,需要合并到(运用MI公司提供的QuickTest Plus中的插件Repositories Merge Utility合并

      http://www.yangfei.org/post/120.html

    1、每个Browser下的Page不要太多,最好不要超过5个,即使我们的系统都在同一个IE窗口下(没有弹出新IE),我们也可以分几个Browser管理,把业务上关联较强的几个Page放在一个Browser下;
    2、每个对象都按照所代表的业务属性命名,最好用中文,不要出现一些难理解的字符,比如abc这样的。
    3、尽量避免在一个tsr文件中堆放过多的对象,最好根据业务,把对象分为几个tsr文件保存。这里没有统一标准,以每个tsr文件结构清晰为宜。

    http://www.51testing.com/?uid-216940-action-viewspace-itemid-218326

     

    QTP对象库管理和编写脚本

    http://blog.csdn.net/aerchi/archive/2010/01/05/5137234.aspx

     

    http://www.w3schools.com/Vbscript/vbscript_looping.asp

     

     

    2.     正则表达式

     我以前就已经知道什么是正则表达式,不过一直没在实际中用过,所以刚开始就想当然地使用。先把我出丑的过程说一遍,刚开始的时候我想检查一个“$123.45”格式。由于只扫了两眼QTP用户指南加上自己主观臆断,正则表达式如下“\$*\.*”。正确答案大家都应该知道了,应该是“\$[0-9]+\.[0-9][0-9]”
            --------------------------------------------------------------------------------
           
    以下是QTP用户手册关于正则表达式的内容

            使用反斜杠字符 ( \ )

            匹配任意单个字符 ( . )

            匹配列表中的任意单个字符 ( [xy] )

            匹配不在列表中的任意单个字符 ( [^xy] )

            匹配某个范围内的任意单个字符 ( [x-y] )

            特定字符的零次或多次匹配 ( * )

            特定字符的一次或多次匹配 ( + )

            特定字符的零次或一次匹配 ( ? )

            对正则表达式进行分组 ( ( ) )

            匹配几个正则表达式中的一个表达式 ( | )

            在一行的开始进行匹配 ( ^ )

            在一行的结尾进行匹配 ( $ )

            匹配包括下划线在内的任一字母数字字符 ( \w )

            匹配任意非字母数字字符 ( \W )

     

    3.     Do where, until

       Do… where

       Perform. a series of statements indefinitely as long as a specified condition is true.

       Do… until

       Perform. a series of statements indefinitely until a specified condition is true.

    4.     描述性编程的语法

     

     

    QTP中使用描述性编程是一个提高QTP脚本利用率的很好的方式。通常QTP是通过对象库来识别不同的对象,而描述性编程是QTP另外一种能够识别对象的途径,它不依赖于对象库,通过增加一些对象的描述来识别对象的。
    说明:本例子是以Flight飞机订票系统的登陆界面为测试页面进行描述的。
    步骤一:录制脚本
     Dialog("Login").WinEdit("Agent Name:").Set "Holly"
     Dialog("Login").WinEdit("Password:").SetSecure "46ef0dc7efe5834c73673898279af1204fea51a7"
     Dialog("Login").WinButton("Cancel").Click
    共录制3步操作,输入Agent Name, Password, 点击Cancel按钮

    步骤二:初级描述性编程
     Dialog("Regexpwndtitle:=Login").WinEdit("Attached text:=Agent Name:").Set "zhangsan"
     Dialog("Regexpwndtitle:=Login").WinEdit("Attached text:=Password:").Set "mercury"
     Dialog("Regexpwndtitle:=Login").WinButton("Class Name:=WinButton", "text:=Cancel").C
    在这里要注意有三点:

    1
    )如果需要两个以上特性来描述一个对象,需要使用逗号(,)对描述性语言进行分割
    2
    )使用:=来连接属性和属性值,并且:=两边不能有空格
    3
    )使用SPY查看对象的属性名和属性值(Tools -> Object Spy
    步骤三:描述性编程提高
     Dim descEditLogin
     Set descEditLogin = Description.Create()
     descEditLogin("Class Name").Value = "Dialog"
     descEditLogin("Regexpwndtitle").Value = "Login"
     Dialog(descEditLogin).WinEdit("Attached text:=Agent Name:").Set "Holly"
     Dialog(descEditLogin).WinEdit("Attached text:=Password:").Set "Mercury"
     Dialog(descEditLogin).WinButton("Class Name:=WinButton", "text:=Cancel").Click
    在这里需要注意有两点:

    1
    )把经常使用到的对象定义为一个对象变量,方便以后调用,减少代码工作量和错误
    2
    )使用SPY获取对象的属性和属性值
    步骤四:使用自定义的环境变量
    File>>Settings>>Environment中选择user-defined,增加一个变量
    dlgLogin =
    Login
    这样脚本可以被修改为:
     Dim descEditLogin
     Set descEditLogin = Description.Create()
     descEditLogin("Class Name").Value = "Dialog"
     descEditLogin("Regexpwndtitle").Value = Environment.Value("dlgLogin")
     Dialog(descEditLogin).WinEdit("Attached text:=Agent Name:").Set "Holly"
     Dialog(descEditLogin).WinEdit("Attached text:=Password:").Set "Mercury"
     Dialog(descEditLogin).WinButton("Class Name:=WinButton", "text:=Cancel").Click
    当然,参数化的方式很多,这边介绍的是使用环境变量

      总结:优点是当对象的一些属性变更后,脚本更容易维护。比如说对于一个通用对象,比如save, reset, cancel等按钮,一个页面有3个,30个页面就有90个对象,假如save变成保存,reset变成重置,cancel变成取消,那么对象库就会产生很大的变动。而使用了描述性编程只需要在导入的XML文件中修改一个值就可以了。当然描述性编程的作用远远不止这些,这次只是抛砖引玉,希望大家共同进步。在QTP中使用描述性编程是一个提高QTP脚本利用率的很好的方式。通常QTP是通过对象库来识别不同的对象,而描述性编程是QTP另外一种能够识别对象的途径,它不依赖于对象库,通过增加一些对象的描述来识别对象的。
      QTP的工作原理有点类似人类社会的某些场景.比如一个朋友委托你带东西给A,如果你认识A,这表明A的容貌特征以及一些联系已经在你脑海有了印象,那么你只要找到了A的住所,那么这个任务就很容易完成了,如果你根本就不认识A,则这个任务就很难完成了. 那在QTP中有没有一种方法,无须在对象库中记录任何关于某个对象的信息,就可以完成对该对象的操作呢,.那就是描述性编程,其工作原理就象上面这个例子
    .
      在QTP,有一按钮对象,对它的操作如下:Dialog("Login").WinButton("OK").Click但是如果我们在对象库中删除这个对象后,执行这句话就会出错,提示找不到对象,在这个时候,我们就可以通过描述性编程给他指定对象及其他的一些属性,修改如下
    Dialog("Login").WinButton("text:=OK").Click
      上面脚本中,通过WinButton("text:=OK")明确告诉QTP去寻找文本属性为OK的按钮,于是QTP正确识别到该对象,顺利的执行了脚本.这种不需要在对象库中存储对象的信息,就可以执行对象操作的方法,就是QTP中比较高级的用法:描述性编程(descrīptive progamming).描述性编程和传统的QTP脚本的区别是:他把需要识别的对象的属性从对象库中转移到了脚本里面,通过在脚本里面的特殊语法格式.来告诉QTP识别对象的方法.描述性编程更加灵活,因为他不需要经过录制这个步骤,可以直接通过编程的方式操作任何一个你想操作的对象,只要你在测试脚本代码里提供给QTP识别该对象的足够信息
      描述性编程的语法格式如下
    :
      
    micClases("property1:=value1","property2:=value2")
      micClass标志某个对象的类别,括号里面通过jproperty:=value的形式告诉QTP识别该对象的必要属性.我们继续修改一下测试脚本:Dialog("Login").WinButton("text:=OK").Click修改后:Dialog("Login").WinButton("nativeclass:=Button","text:=OK").ClickF5执行,结果运行顺利.这次修改,我们使用了一个通用的对象类WinObject,而把按钮当作一个基本属性nativeclass:=Button,同样可以完成对该按钮的操作
      由上面的叙述我们可以看出来,描述性编程没有严格的要求,只要遵循一个原则:在代码中告诉QTP足够他识别该对象的属性,QTP就可以不通过对象库,而是通过描述性编程的方式完成对指定对象的操作.所以描述性编程没有什么神秘的,他无非是把原来存储在对象库中的信息提到代码中来了而已.

    1. 如何管理report
    http://www.7dtest.com/site/html/26/t-3426.html
  • 【QTP实战】在WebTable对象中使用ChildItem方法

    2011-05-03 16:23:09

     

    ChildItem方法
    语法:
    object.ChildItem (Row,Column,MicClass,Index)

    作用:用于获取单元格中的测试对象

    项目实战举例:
    1、修改订单号为“DD0000315”的单据,点击操作列中对应的“修改”图标进入修改页面。

    orderNo="DD0000315"
    num=Browser("xx").Page("xx").Frame("xx").WebTable("xx").RowCount
    For i=0 to num
       If Browser("xx").Page("xx").Frame("xx").WebTable("xx").GetCellData(i,2)=orderNo Then
       Browser("xx").Page("xx").Frame("xx").WebTable("xx").ChildItem(i,9,"WebElement",0).Click
    'Index:0=修改,1=提交,2=入库通知,3=审核,5=打印
       End If
    Next

    2、选择订单号为“DD0000317”前面的复选框,点击操作栏中的的“提交”图标进入提交页面。

    orderNo="DD0000317"
    totalRowNumber=Browser("xx").Page("xx").Frame("xx").WebTable("xx").RowCount
    For i=0 to totalRowNumber
     If Browser("xx").Page("xx").Frame("xx").WebTable("xx").GetCellData(i,2)=orderNo Then
        Browser("xx").Page("xx").Frame("xx").WebTable("xx").childitem(i,1,"WebCheckBox",0).Set "ON"
     End if
    Next
    Browser("xx").Page("xx").WebButton("提交").Click

    >>项目实战操作图:

     

    ChildItem

    Description

        Returns a test object from the cell by type and index.

    Syntax

        object.ChildItem(Row,column,MicClass,Index)

        object:A test object of type WebTable.

        Row:Required.A long value.The row number where the cell is located.The first row int the table is number 1.

        Column:Required.A long value.The column number where the cell is located.The first column in the table is 1.

        MicClass:Required.A string value.The object type.

        Index:Required.A long value.The index of the object of type MicClass in the cell.This index indicates the desired element when there is more then one object of the type MicClass in the cell.The first object has an index of 0.

    Return Value

        An Object object

    Example

        sub ChildItem_Example()

        'The following example uses the ChildItem method to set the second edit box from the FirstName table to Example.

        Set WebEditObj = Browser().Page().WebTable("FirstName").ChildItem(8,2,"webedit",0)

        WebEditObj.Set "Example"

        End sub

  • 如何点选table中第一行的值 进行右键的相关操作

    2011-05-03 16:11:45

     
     
    setting.webpackage("ReplayType")=2
    Dim obj2
    Dim rowNum2
    Set Desc = Description.Create()
    Desc("micclass").Value ="WebTable"
    Desc("text").Value ="Document Source SystemDocument TypeDateOwnerStatusDocument NumberEntry NumberPurchase OrderStyle. IdDocument CurrencyPagerPage.*"
    Set editobjects=Browser("Actual Costing System").Page("Document").ChildObjects(Desc)
    fCount=Browser("Actual Costing System").Page("Document").ChildObjects(Desc).Count
    For i=0 to fCount-1
      Set obj2=editobjects(i)
      rowNum2=obj2.GetRowWithCellText("DAMCO")
      obj2.ChildItem(rowNum2,1,"WebElement",0).Click ,,micRightBtn
      obj2.ChildItem(rowNum2,1,"WebElement",0).Click 2,2,micRightBtn
      Exit for
    Next
    setting.webpackage("ReplayType")=1
    'Browser("Actual Costing System").Page("Document").WebElement("Document Detail").Click
    Browser("Actual Costing System").Page("Document").WebElement("DocumentEdit").Click
    'Browser("Actual Costing System").Page("Document").WebElement("Matching Receipts").Click
    '
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''Hemisphere
  • 转一位同学的校友录留言,牛啊

    2008-09-01 20:55:01

    都说女人如衣服,兄弟如手足,回想起来,我竟然七手八脚地裸奔了二十几年。2007年的年末,不幸遭遇了N多年不遇的暴风雪,连温暖的南方都没法继续奔了。那时才真正发现“衣服”的重要性,于是,找一个能让自己温暖的女人,相濡以沫、相亲相爱、相敬如宾、相辅相成,执子之手,与之偕老。兄弟姐妹们,我结婚了!
    结婚之前,我们也有很多的担忧,担忧金钱、担忧感情、担心责任、担心自由……但最重要的东西都在两个人的心里,只要相信,就无所畏惧。其实,幸福很简单。
    在家品味幸福的时间溜特别地快,回到工作中总是忙啊忙啊,没有尽头。但不管多忙,心里总有牵挂和期盼, 不想以前,没根没落的。
    幸福是能让自己不自觉地感到愧疚的。没钱,买戒指的时候,让老婆挑,她故意挑了一枚便宜的,说自己喜欢简单的款式;没时间,老婆的假期比我多,总是没有时间陪她,没本事,一个人奔了这么多年,没有什么拿得出手的东西,要啥没啥……时常觉得自己一无是处了。兄弟们,不努力不行啊!
    今年的中国人民经历的苦难太多。希望我的这些小小的幸福能够与你们分享。不管怎样,其实幸福离我们不远。生活还在继续,兄弟姐妹们,一起努力吧!

     

    大家要是觉得写的好就支持下吧

  • 端午节

    2008-06-08 22:41:28

         今天是端午节,跟大学一个姐门 好好的玩了一天。感觉现在朋友更重要,男人都是靠不住的。

    早上两个人一觉睡到了12点,呵呵。(很有威力吧,没有2,3年的功底,练不成这样)。

    起床后,一起过个早,一人一杯热豆浆。然后按照昨天的计划进行,去菜市场买菜做饭,毕竟今天是过节啊。

    买了:2条黄鱼,1个西南花,一个新鲜的冬笋。回家,做饭。

    香煎黄鱼,凉拌西南花,清炒冬笋。

    搞定,尝尝,鱼不错,西南花也很爽口,可冬笋怎么那么苦呢,上网查了一下,不是我一个人炒出来的是苦的呵呵,那是大家都做的是苦的。(自我解脱的说法)

    中午一人一个粽子,我吃的那个叫火炬粽。真是厉害啊。

     吃完饭,二人决定去洗头发,找了家不错的店子,带按摩和吹头发一共折腾了2个小时,好爽,出来的时候,两个人完全变了样,心情也顿时好了起来,感觉女人的心情很容易变化,一点点小感动,有时候一句好听的话,人马上开始飘飘然,同样一个新的发型,然我顿时high了起来。

    之后逛街,吃小食。总之一直混到9点多,当然也少不了对各自男朋友的数落,2个女人在一起一定少不了的话题呵呵。总之很放松。

    随后小罗接到他男朋友的电话。

    我吃水果都是最好吃的,越贵越买,你说我虚荣也好,奢侈也好,我喜欢,我高兴就好,反正你也不能在我身边陪我,我就帮你把加班费消费光好了。当孤独寂寞的时候,只能用消费来证明自己的存在。

    吃个冰淇淋人的幸福指数会增加很多,

    我想有个漂亮发型,和一个不错的朋友呆上一天,幸福指数也是会上涨的。

     

    祝大家端午节快乐。

    让烦恼都走开

     

                                                              2008.6.8

     

     

     

  • 招聘 软件测试,初级测试

    2008-05-31 13:00:24

    月薪4-7k,要求英语听说读写。工作地点深圳福田,有意向者可以直接回贴。美资。主要是黑盒测试。

  • 工作和生活

    2008-04-10 17:08:27

    做测试已经有板有3年时间了,感觉测试是一个挑战人极限的工作,没有好的耐心没有好的脾气这份工作基本上是做不好的.

    感觉每到一定的时间,就会想东想西,也就是找不着北,不知道自己想要做什么了.

    在别人眼里测试就是一份轻松而且无聊的工作,实则不然,只有做过的人才知道其中的辛酸.

    现在又到了职业规划的时候了,是继续走测试技术的道路,还是往管理方向发展呢.

    不管走那一步都不件容易的事情,要付出,付出, 机会,机会.

  • 本人终于要跳出苦海了

    2007-11-15 16:20:18

        经过了接近2年的潜伏期,本人终于跳槽成功,而且一次就搞定两个,虽然不是特别好的工作,但是至少让我肯定了自己,以前每次面试都失败,搞的自己都没信心了,现在成功了,我要大小 哈哈哈哈哈哈哈。

       下个星期就要去新公司上班了,虽然压力也是有的,但是还是兴奋。

  • VSTS 配置过程

    2007-09-27 14:40:44

    一.在服务器上添加客户端的用户

    1 选择My Computer,右键选择manage

    2 选择local users and Group,右键点击new user,添加一个客户端的user

    3 然后双击该用户,在member of里面加到别的用户组 

      loadtest 专业名词解释

    Transaction

    ThinkTime

    Avg Page

    Response Time

     

     

    测试环境的配置。

    1status server的环境

       要把status serverApp Data Server设置在不同的机器上.

     

    2View status 改为Sql Servers

     

    3Windows2003IIS 上配置。

       选择IIS的管理

       应用的内存是总内存的%60。虚礼内存是实际内存的2倍。

     

     

    四.数据绑定

       1.参数化数据库

            选择web scrīpt,右键添加Add Data Source,

            server or file name 中输入文件名和文件路径。

       2Excel的添加:

           扩展属性:  Excel 8.0

           name 中输入文件名和文件路径.

      3Txt文本文档的添加

            扩展属性:  text

             name 中输入文件路径.

     

     VSTS中添加上下文参数。

       1 选择请求的大标题,右键选择Add context parameter, 选择parameter 1 右键点击properties

     name 字段中输入参数名。Value 字段可以输入1 或是不输入。

     

     

    Load test 参数设置。

     1 Think Time

     

    未完待续

     

  • 用excel参数化字段

    2007-09-26 16:14:21

    在进行webtest的过程中,我们会遇到参数从一个页面无法传递到第二个页面的问题。

    这个时候需要对业务熟悉,了解在参数传值得过程中的字段。

     

  • VSTS中如何添加服务器?

    2007-09-26 11:46:15

    在VSTS中要监控服务器的性能,所以就必须把服务器添加到Loadtest中,步骤如下:

    1 选择一个项目,点击右键选择添加Loadtest,在counts seting中点击添加服务器

    2 输入服务器名称,选择需要关注的计数器。

    如果添加成功在loadtest中可以看到该服务器。

    添加服务器的前提条件是:客户端可以自由访问服务器。

    在客户端的设置是:




521/3123>
Open Toolbar