终生学习,态度决定行为,行为培养习惯,习惯形成性格,性格决定命运。

发布新日志

  • (转载)如何在LR中做关联

    2009-11-19 18:02:15

    问题出现:
    n    VuGen替代浏览器,脚本是hard-coded
    n    HTTP是一种无状态的连接
    n    同一用户两次登录的差异
    n    单用户和多用户的差异(验证机制:session)
     
    关于session
     
    n    记录用户的状态
    n    验证用户的身份
    n    在服务端创建并保存(永久的和临时的)
    n    Session也保存在客户端,提交到服务器端验证(URL重写和cookies)
    问题分析
    n    用一种方法来满足服务器的验证。
    n    保存来自服务器端的session,并传递给提交语句以保证验证通过。
     
     
    需要关联的数据的特征
     
     
    n    1,数据是从服务器传过来的。
     
    n    2,数据是可变的。
     
    VuGen与服务器的交互
    关联的主要条件
    n    1,简化或者优化代码。
    n    2,动态数据。
    n    3,提供唯一的数据。
    如何鉴定什么样的错误需要关联
    n    会出现什么错误讯息,与系统实做的错误处理机制有关。
    n    错误讯息有可能会提醒您要重新登入,但是也有可能直接就显示HTTP 404的错误讯息。
    n    在LR的LOG中也有些错误的提示:比如:27979等的错误(错误的原因是多种的,关联只是引起错误的一种原因)。
    LR中需要用到的关联函数
    n      web_create_html_param Saves dynamic information on an HTML page to a parameter. (Obsolete: use only for LR 6.5 and below)
    n      web_create_html_param_ex Saves recurring dynamic information on an HTML page to a parameter. (Obsolete: use only for LR 6.5 and below)
    n       web_reg_save_param Saves non-NULL terminated dynamic data from an HTML page to a parameter.
    n      web_save_param_length Saves the length of a parameter
    n      web_save_timestamp_param Saves the current timestamp. web_set_max_html_param_len Sets the maximum length of retrieved dynamic HTML information.
    VuGen的关联方法
     
     
    n    自动关联
     
    n    手动关联
    自动关联
    n    record options--->correlation中启用enable correlation during recording recording.LR会用自已的关联规则来匹配需要关联的脚本

    手动关联
    n    步骤:
    1,录制。
    2,回放。
    3,回放出错后开启LOG。
    4,出错后查看LOG。(定位到某一行)
    5,再重新录制一下脚本,把两份脚本对比。
     
     
     
    录制回放
    n    回放出错如下:
    Action.c(37): Error -27979: Requested form. not found     [MsgId: MERR-27979]

    Action.c(37): web_submit_form("com.mercurytours.servlet.IteneraryServlet") highest severity level was "ERROR", 0 body bytes, 0 header bytes         [MsgId: MMSG-26388]

     

    开启LOG查找需要关联的数据
    n    run-time settings-->Log,设置Extened log.
    n    再次回放。
    n    定位需要关联的数据。(单协议在recording log,多协议在Generation Log中查到数据)
     
    写关联函数
    n      char GlParam1_Text1;//定义变量
     
    n      web_reg_save_param("GlParam1_Text1",
    n                "LB= name=\"",
    n                "RB=\"",
    n                "Ord=all",
    n                "RelFrameId=1",
    n                "Search=Body",
    n                "IgnoreRedirections=Yes",
    n                LAST);
    n      在下面的语句中来调用: GlParam1_Text1
     
     
     
     
    关联函数的位置
    n     It registers a request to find and save a text string within the server response. The operation is performed only after executing the next action function, such as web_url. (from help).
    n     定位到变量的那一行的上面。
     
    Note:引用web_reg_save_param中的变量时,要用{}。
    要打印出来,用lr_evel_string取值。
    一些说明:
    n     开启WinDiff时出现File no longer available的错误信息
    WinDiff这个工具有些限制,脚本路径不能有空格。
    n     ctrl+F8可以扫描脚本中需要关联的地方


     

Open Toolbar