51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2690|回复: 0
打印 上一主题 下一主题

[原创] SAP ECC 测试脚本

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2009-2-13 12:08:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/* -------------------------------------------------------------------------------
        Script Title       :
        Script Description :
                        
                        
        Recorder Version   : 824
   ------------------------------------------------------------------------------- */

vuser_init()
{
        //log into d7d
        /*sapgui_open_connection_ex("   /SAP_CODEPAGE=1100  /FULLMENU  hprplm05.canada.hp.com 00 /3",
                "D7D - R/3 QA (IHP)",
                "con[0]");
*/
//D7B:
sapgui_open_connection_ex("   /SAP_CODEPAGE=1100  /FULLMENU  dbcid7b.canada.hp.com 00 /3",
                "D7B",
                "con[0]");

        sapgui_select_active_connection("con[0]");

        sapgui_select_active_session("ses[0]");

        sapgui_select_active_window("wnd[0]");

        sapgui_window_resize("146",
                "26",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui102",
                END_OPTIONAL);

        /*Before running script, enter password in place of asterisks in logon function*/

        lr_think_time(5);
       

        lr_start_transaction("Logon");

        sapgui_logon("QATESTER",
                lr_decrypt("4021821bef15d2ded06e498d"),
                "300",
                "EN",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui108",
                END_OPTIONAL);

        lr_end_transaction("Logon", LR_AUTO);


        return 0;
}
ALL_JOBS()
{
        sapgui_set_ok_code("sm37",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui109",
                END_OPTIONAL);

        sapgui_send_vkey(ENTER,
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1010",
                END_OPTIONAL);

        lr_think_time(10);

        sapgui_set_checkbox("Sched.",
                "True",
                "usr/chkBTCH2170-PRELIM",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1011",
                END_OPTIONAL);
        sapgui_set_checkbox("Released",
                "False",
                "usr/chkBTCH2170-SCHEDUL",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1041",
                END_OPTIONAL);

        sapgui_set_checkbox("Ready",
                "False",
                "usr/chkBTCH2170-READY",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1042",
                END_OPTIONAL);

        sapgui_set_checkbox("Active",
                "False",
                "usr/chkBTCH2170-RUNNING",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1043",
                END_OPTIONAL);

        sapgui_set_checkbox("Finished",
                "False",
                "usr/chkBTCH2170-FINISHED",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1044",
                END_OPTIONAL);

        sapgui_set_checkbox("Canceled",
                "False",
                "usr/chkBTCH2170-ABORTED",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1045",
                END_OPTIONAL);

        sapgui_set_text("BTCH2170-JOBNAME",
                "{JobName}",
                "usr/txtBTCH2170-JOBNAME",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1012",
                END_OPTIONAL);

        sapgui_set_text("BTCH2170-USERNAME",
                "*",
                "usr/txtBTCH2170-USERNAME",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1013",
                END_OPTIONAL);

        sapgui_set_focus("usr/txtBTCH2170-USERNAME",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1014",
                END_OPTIONAL);
       
        sapgui_press_button(" Execute",
                "tbar[1]/btn[8]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1016",
                END_OPTIONAL);

    lr_think_time(10);

        sapgui_window_scroll_to_row("0",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1049",
                END_OPTIONAL);
        //Choose the matching job checkbox       
        sapgui_set_checkbox("chk[1,12]",
                "True",
                "usr/chk[1,12]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1048",
                END_OPTIONAL);

        sapgui_set_focus("usr/lbl[4,12]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1050",
                END_OPTIONAL);
        //Choose COPY
        sapgui_send_vkey("30",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1054",
                END_OPTIONAL);

        lr_think_time(6);

        sapgui_select_active_window("wnd[1]");
        //give the new job a new name
        sapgui_set_text("New job name",
                "{JobName}_QA",
                "usr/txtBTCH1180-JOBNAME",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1055",
                END_OPTIONAL);

        sapgui_press_button(" Copy",
                "tbar[0]/btn[0]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1057",
                END_OPTIONAL);

        lr_think_time(5);

        sapgui_select_active_window("wnd[0]");


        sapgui_press_button("Back   (F3)",
                "tbar[0]/btn[3]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1020",
                END_OPTIONAL);

        sapgui_set_text("BTCH2170-JOBNAME",
                "{JobName}_QA",
                "usr/txtBTCH2170-JOBNAME",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1017",
                END_OPTIONAL);

        sapgui_press_button(" Execute",
                "tbar[1]/btn[8]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1019",
                END_OPTIONAL);


        sapgui_window_scroll_to_row("0",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1059",
                END_OPTIONAL);
//        Choose the new copied job
        sapgui_set_checkbox("chk[1,13]",
                "True",
                "usr/chk[1,12]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1058",
                END_OPTIONAL);

        sapgui_set_focus("usr/chk[1,12]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1060",
                END_OPTIONAL);

        sapgui_press_button(" Release",
                "tbar[1]/btn[46]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1062",
                END_OPTIONAL);

        lr_think_time(5);

        sapgui_select_active_window("wnd[1]");

        sapgui_press_button("Immediate",
                "usr/btnSOFORT_PUSH",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1063",
                END_OPTIONAL);

        sapgui_press_button(" Check",
                "tbar[0]/btn[0]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1064",
                END_OPTIONAL);

        sapgui_press_button("Save   (Ctrl+S)",
                "tbar[0]/btn[11]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1065",
                END_OPTIONAL);

        lr_think_time(10);

        sapgui_select_active_window("wnd[0]");

        //change the query
        sapgui_press_button("Back   (F3)",
                "tbar[0]/btn[3]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui3018",
                END_OPTIONAL);

        lr_think_time(5);

        sapgui_set_checkbox("Sched.",
                "False",
                "usr/chkBTCH2170-PRELIM",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui3019",
                END_OPTIONAL);

        sapgui_set_checkbox("Released",
                "False",
                "usr/chkBTCH2170-SCHEDUL",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui3020",
                END_OPTIONAL);

        sapgui_set_checkbox("Ready",
                "False",
                "usr/chkBTCH2170-READY",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui3021",
                END_OPTIONAL);
        sapgui_set_checkbox("Active",
                "True",
                "usr/chkBTCH2170-RUNNING",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1043",
                END_OPTIONAL);

        sapgui_set_checkbox("Finished",
                "True",
                "usr/chkBTCH2170-FINISHED",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1044",
                END_OPTIONAL);

        sapgui_set_checkbox("Canceled",
                "False",
                "usr/chkBTCH2170-ABORTED",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui3022",
                END_OPTIONAL);

        lr_start_transaction(lr_eval_string("{JobName}"));
        sapgui_press_button(" Execute",
                "tbar[1]/btn[8]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui3024",
                END_OPTIONAL);
       
        //Sort the Status in Ascending Order:
        sapgui_set_focus("usr/lbl[56,10]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui3025",
                END_OPTIONAL);

        sapgui_send_vkey(F2,
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui3029",
                END_OPTIONAL);

        sapgui_press_button("Sort in ascending order   (Ctrl+Shift+F5)",
                "tbar[1]/btn[41]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui3031",
                END_OPTIONAL);

        sapgui_get_text("Status",
                "usr/lbl[56,12]",
                "isActive",
                END_OPTIONAL);
       

        while (strcmp(lr_eval_string("{isActive}"),"Activ")==0){
        //        lr_output_message("isACTIVE: %s", lr_eval_string("{isActive}"));       
                sleep(10000);

                sapgui_press_button("Refresh   (F8)",
                "tbar[1]/btn[8]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui3042",
                END_OPTIONAL);
       
                sapgui_get_text("Status",
                "usr/lbl[56,12]",
                "isActive",
                END_OPTIONAL);

        }
       
        if(strcmp(lr_eval_string("{isActive}"),"Complete")==0){
                lr_end_transaction(lr_eval_string("{JobName}"), LR_PASS);
        }
        else{
                lr_error_message("{JobName} did not finish.  STATUS: %s", lr_eval_string("{isActive}"));
                lr_end_transaction(lr_eval_string("{JobName}"), LR_FAIL);
        }
               
        /*
        sapgui_get_text("Execution Time",
                "usr/lbl[94,12]",
                "totalTime",
                END_OPTIONAL);

        lr_output_message("The job took: %s minutes to complete",lr_eval_string("{totalTime}"));
*/       

        sapgui_press_button("Back   (F3)",
                "tbar[0]/btn[3]",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1078",
                END_OPTIONAL);

        sapgui_set_ok_code("/ns000",
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1079",
                END_OPTIONAL);

        sapgui_send_vkey(ENTER,
                BEGIN_OPTIONAL,
                        "AdditionalInfo=sapgui1080",
                END_OPTIONAL);

        return 0;
}
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-9-27 21:21 , Processed in 0.077276 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表