51Testing软件测试论坛

标题: SAP ECC 测试脚本 [打印本页]

作者: wofeman    时间: 2009-2-13 12:08
标题: SAP ECC 测试脚本
/* -------------------------------------------------------------------------------
        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;
}




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2