自动关联

  在录制脚本之后打开recording Options 窗口,点击correlation标签页。确保Enable correlation during recording 选项处于勾选状态。

  在LoadRunner 自带WebTours为例设置关联,

  访问WebTours首页,点击administration 链接,设置 Set LOGIN form's action tag to an error page.勾选更新。

  录制WebTours登录与退出脚本:

Action()
{

    web_url("WebTours",
        "URL=http://127.0.0.1:2080/WebTours/",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t1.inf",
        "Mode=HTML",
        LAST);

    web_url("favicon.ico",
        "URL=http://127.0.0.1:2080/favicon.ico",
        "Resource=1",
        "Referer=",
        LAST);

    web_submit_data("login.pl",
        "Action=http://127.0.0.1:2080/WebTours/login.pl",
        "Method=POST",
        "Referer=http://127.0.0.1:2080/WebTours/nav.pl?in=home",
        "Mode=HTML",
        ITEMDATA,
        "Name=userSession", "Value=110381.833940867fzHHHzfpfiDDDDDDDtAzzpfQDf", ENDITEM,
        "Name=username", "Value=test", ENDITEM,
        "Name=password", "Value=123456", ENDITEM,
        "Name=JSFormSubmit", "Value=on", ENDITEM,
        LAST);

    web_submit_data("login.pl_2",
        "Action=http://127.0.0.1:2080/WebTours/login.pl",
        "Method=POST",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:2080/WebTours/nav.pl?in=home",
        "Snapshot=t2.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=userSession", "Value=110381.833940867fzHHHzfpfiDDDDDDDtAzzpfQDf", ENDITEM,
        "Name=username", "Value=test", ENDITEM,
        "Name=password", "Value=123456", ENDITEM,
        "Name=JSFormSubmit", "Value=on", ENDITEM,
        "Name=login.x", "Value=52", ENDITEM,
        "Name=login.y", "Value=1", ENDITEM,
        LAST);

    web_image("SignOff Button",
        "Alt=SignOff Button",
        "Snapshot=t3.inf",
        LAST);

    return 0;
}