LoadRunner通过嵌套关联解析Gognos响应动态数据

发表于:2010-2-04 14:27

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:sinckyzhang(搜狐博客    来源:51Testing软件测试网采编

  IBM Cognos是面向企业的业务智能(BI)和绩效计划软件的全球领导者。如今很多国内外公司基于Cognos二次开发来实施企业报表信息管理系统,那么对 Cognos的性能测试油然而生!由于Cognos Web上的异步XML数据提交的特定技术,造成Loadrunner无法正确录制和模拟这种异步响应,那么该怎么办呢?

请char *pEnd;
clickReport()
{
     char *str = (char *)malloc(10240);
     char *pall = (char *)malloc(10240);
     char *left = "option value="", *right = """;


     getAsyncInfo();

     web_reg_find("Text=Click on the", "SaveCount=successfulReport", "Search=All", LAST);


     web_link("ClickReportNameLink",
         "Text=SinckyLinkName",
         "Snapshot=t6.inf",
         LAST);

     if ((atoi(lr_eval_string("{successfulReport}"))==0)){

         do{
             sendAsyncWaitResponse();
         }while(atoi(lr_eval_string("{statusWaiting}"))>0);

     }


     strcpy(str, lr_eval_string("{var_selectmeetingstatus}"));

     handleMidStr(str, left, right, pall);

     for(pall; pall < pEnd; pall += strlen(pall)+1 ) {
         lr_log_message("pall is : %s\n", pall);
     }

     free(str);
     free(pall);

     return 0;
}


void getAsyncInfo()
{
     web_reg_save_param("var_actionState", "LB=action_state\": \"", "RB=\"", LAST);
     web_reg_save_param("var_executionParameters", "LB=parameters\": \"", "RB=\"", LAST);
     web_reg_save_param("var_ui.conversation", "LB=conversation\": \"", "RB=\"", LAST);
     web_reg_save_param("var_m_tracking", "LB=tracking\": \"", "RB=\"", LAST);
     web_reg_save_param("var_ui.cafcontextid", "LB=caf\": \"", "RB=\"", LAST);
     web_reg_save_param("var_asyncStatus", "LB=\"status\": \"", "RB=\"", LAST);
     return;
}


void getAsyncInfo_HTMLFragment()
{
     web_reg_save_param("var_actionState", "LB=action_state&quot;: &quot;", "RB=&quot;", LAST);
     web_reg_save_param("var_executionParameters", "LB=parameters&quot;: &quot;", "RB=&quot;", LAST);
     web_reg_save_param("var_ui.conversation", "LB=conversation&quot;: &quot;", "RB=&quot;", LAST);
     web_reg_save_param("var_m_tracking", "LB=tracking&quot;: &quot;", "RB=&quot;", LAST);
     web_reg_save_param("var_ui.cafcontextid", "LB=caf&quot;: &quot;", "RB=&quot;", LAST);
     web_reg_save_param("var_asyncStatus", "LB=&quot;status&quot;: &quot;", "RB=&quot;", LAST);
     web_reg_save_param("var_meetingstatus_list", "LB=&quot;status&quot;: &quot;", "RB=&quot;", LAST);
     web_reg_save_param("var_selectmeetingstatus", "LB=multiple&gt;&lt;", "RB=Select Budget Type", LAST);
     return;
}


void sendAsyncWaitResponse()
{

     getAsyncInfo_HTMLFragment();

     web_reg_find("Text=Text=&quot;status&quot;: &quot;working", "SaveCount=statusWaiting", "Search=All", LAST);

     web_reg_find("Text=Click on the", "SaveCount=successfulReport", "Search=All", LAST);

     web_submit_data("WaitResponse",
         "Action=https://sinckyurl/cgi-bin/cognos-reporting.cgi",
         "Method=POST",
         "RecContentType=text/plain",
         "Referer=",
         "Mode=HTML",
         ITEMDATA,
         "Name=cv.header", "Value=false", ENDITEM,
         "Name=b_action", "Value=cognosViewer", ENDITEM,
         "Name=cv.id", "Value=_NS_", ENDITEM,
         "Name=ui.action", "Value=wait", ENDITEM,
         "Name=cv.actionState", "Value={var_actionState}", ENDITEM,
         "Name=ui.primaryAction", "Value=run", ENDITEM,
         "Name=errURL", "Value=javascript:close()", ENDITEM,
         "Name=executionParameters", "Value={var_executionParameters}", ENDITEM,
         "Name=ui.conversation", "Value={var_ui.conversation}", ENDITEM,
         "Name=m_tracking", "Value={var_m_tracking}", ENDITEM,
         "Name=ui.cafcontextid", "Value={var_ui.cafcontextid}", ENDITEM,
         "Name=cv.catchLogOnFault", "Value=true", ENDITEM,
         "Name=cv.responseFormat", "Value=data", ENDITEM,
         LAST);

    return;
}

void  handleMidStr(char *str, char *left, char *right, char *pall)

{

    char *p1, *p2;
    int leftLen = strlen(left);
    int rightLen = strlen(right);
 
    if( strlen(str) > 0) {
        p1 = (char *)strstr(str, left);
        if (p1 != NULL )
            p1 = p1 + leftLen;
        else
            return ;

        p2 = (char *)strstr(p1, right);
        if (p2 == NULL )
            return ;
 
        memcpy(pall, p1, p2 - p1);
        pall[p2 - p1] = 0;
        pall += p2 - p1 + 1;
        pEnd = pall;
 
        handleMidStr(p2+rightLen, left, right, pall);

    }

}

《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号