问题出现:
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]