LR 细节解析,为什么LR脚本会去访问“脚本中不存在的“资源?

发表于:2012-5-08 11:03

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

 作者:薛定谔的破猫    来源:51Testing软件测试网采编

  结论

  到这里结论其实也就出来了。(结论只针对HTML-Based Mode录制方式)

  HTML页面中的资源,如页面里写的<img>(跟是不是在表格中无关...),是不会显示在脚本中的。

  而外部链接中的资源,如<link type="text/css>连接的CSS文件中使用的图片,是会通过EXTRARES属性显示在脚本中的。

  运行上面这个脚本,Replay Log中会显示:

Action3.c(8): Downloading resource http://search.thunisoft.com/skins/default/images/bg_top.gif (specified by argument number 9)     [MsgId: MMSG-26577]
Action3.c(8): Downloading resource http://search.thunisoft.com/skins/default/images/nav_bg.gif (specified by argument number 11)     [MsgId: MMSG-26577]
Action3.c(8): Downloading resource http://search.thunisoft.com/skins/default/images/nav_right.jpg (specified by argument number 13)     [MsgId: MMSG-26577]
Action3.c(8): Downloading resource http://search.thunisoft.com/skins/default/images/search_m.gif (specified by argument number 15)     [MsgId: MMSG-26577]
Action3.c(8): Downloading resource http://search.thunisoft.com/skins/default/images/button02.gif (specified by argument number 17)     [MsgId: MMSG-26577]
Action3.c(8): Downloading resource http://search.thunisoft.com/skins/default/images/nav_r.gif (specified by argument number 19)     [MsgId: MMSG-26577]
Action3.c(8): Downloading resource http://search.thunisoft.com/skins/default/images/button01.gif (specified by argument number 21)     [MsgId: MMSG-26577]
Action3.c(8): Downloading resource http://search.thunisoft.com/skins/default/images/nav_l.gif (specified by argument number 23)     [MsgId: MMSG-26577]
Action3.c(8): Downloading resource http://search.thunisoft.com/skins/default/images/search_l.gif (specified by argument number 25)     [MsgId: MMSG-26577]
Action3.c(8): Downloading resource http://search.thunisoft.com/skins/default/images/search_r.gif (specified by argument number 27)     [MsgId: MMSG-26577]

  细心的人可以发现,这个日志和第一步实验中的不一样呢。再次对比上面写出的两种Replay Log,可以发现一个是"Found resource ... in HTML ...",一个是"Downloading resource ..."(标记蓝色两处)

  这样也可以解释了。

  HTML文件内部的资源,不需要显示在脚本中就可以下载,因为会在访问这个页面时“发现”。

  而外部链接的资源,必须在脚本中显式写出,才会去“下载”。

  所以EXTRARES属性下面的资源,只要注释掉相应的脚本,就可以避免该请求。

  而HTML页面文件中的资源,则只能通过修改MODE="HTTP"属性,或者改为URL-Based Mode录制方式,才能避免请求。

  说到这,基本都清楚了,最后再翻一下官方文档(Function Reference)吧。

web_url

EXTRARES:
A demarcation parameter indicating that the next parameter will be a list of resource attributes.

List of Resource Attributes:
A list of resources generated by non–HTML mechanisms in the Web page. These include the resources requested by Javascript, ActiveX, Java applets and Flash. VuGen's Recording Options allow these elements either to be recorded within the current script step (the default mode) or recorded as separate steps (see "Recording in HTML–Based Mode" in the VuGen Online Book).

  再次验证了我们的结论,EXTRARES中只显示非HTML文件中的资源。

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

关注51Testing

联系我们

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

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

沪ICP备05003035号

沪公网安备 31010102002173号