前几篇简单的介绍了怎么具体来操作以捕获手机访问应用服务时产生的真实数据,然后导入LR通过分析自动生成脚本的过程,今天我们就一起来看一个实际的例子。其实跟传统的类似,主要是怎么获取真实的数据来模拟。

 

以下为访问手机访问百度后生成的脚本

C代码 LR 在手机应用服务性能测试中的应用 _手机应用 LR 在手机应用服务性能测试中的应用 _手机应用_02
  1. <SPAN>Action()
  2. {
  3.  
  4. /* Correlation comment - Do not change! Original value='0C91CF80CDC525DAE788207F50FC4651:FG=1' Name ='CorrelationParameter' */
  5. web_reg_save_param_regexp(
  6. "ParamName=CorrelationParameter",
  7. "RegExp=BAIDUID=(.*?);",
  8. SEARCH_FILTERS,
  9. "Scope=Cookies",
  10. "IgnoreRedirections=Yes",
  11. "RequestUrl=*/m.baidu.com/*",
  12. LAST);
  13.  
  14. web_url("r",
  15. "URL=http://miui.com/r?url=httpXXXXXXXXXXXXXXXXX", '特殊处理
  16.  
  17. "Resource=0",
  18. "RecContentType=text/html",
  19. "Referer=",
  20. "Snapshot=t7.inf",
  21. "Mode=HTML",
  22. EXTRARES,
  23. "Url=http://m.baidu.com/static/index/innovation/cache.manifest", "Referer=", ENDITEM,
  24. "Url=http://m.baidu.com/static/index/i.gif", "Referer=", ENDITEM,
  25. "Url=http://m.baidu.com/static/index/logo_index2.png", "Referer=", ENDITEM,
  26. "Url=http://m.baidu.com/static/hb/hot.gif", "Referer=", ENDITEM,
  27. "Url=http://m.baidu.com/static/tj.gif?prod=default&type=loadpagetime_350&time=1357630293617&from=index", "Referer=http://m.baidu.com/?from=1269a", ENDITEM,
  28. "Url=http://m.baidu.com/static/tj.gif?prod=default&type=pv&pt=index&time=1357630293653&from=index", "Referer=http://m.baidu.com/?from=1269a", ENDITEM,
  29. "Url=http://m.baidu.com/static/index/baisou_android.png", "Referer=", ENDITEM,
  30. "Url=http://m.baidu.com/static/index/baisou_iphone.png", "Referer=", ENDITEM,
  31. "Url=http://a.m.baidu.com/rtstatic/index?&module=index&session=baiduapp&item=show", "Referer=http://m.baidu.com/?from=1269a", ENDITEM,
  32. "Url=http://m.baidu.com/favicon.ico", "Referer=http://m.baidu.com/?from=1269a", ENDITEM,
  33. "Url=http://m.baidu.com/su?p=3&ie=utf-8&from=wise_web&wd=%E5%A4%A9%E6%B0%94&t=1357630299189", "Referer=http://m.baidu.com/?from=1269a", ENDITEM,
  34. LAST);
  35.  
  36. web_add_cookie("BAIDUID={CorrelationParameter}; DOMAIN=m.baidu.com");
  37.  
  38. web_add_cookie("BAIDUID={CorrelationParameter}; DOMAIN=wap.baidu.com");
  39.  
  40. web_add_cookie("BAIDUID={CorrelationParameter}; DOMAIN=opendata.baidu.com");
  41.  
  42. web_add_cookie("BAIDUID={CorrelationParameter}; DOMAIN=a.m.baidu.com");
  43.  
  44. web_add_cookie("lsv=2012122801; DOMAIN=a.m.baidu.com");
  45.  
  46. web_url("s",
  47. "URL=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=",
  48. "Resource=0",
  49. "RecContentType=text/html",
  50. "Referer=http://m.baidu.com/?from=1269a",
  51. "Snapshot=t8.inf",
  52. "Mode=HTML",
  53. EXTRARES,
  54. "Url=/static/index/innovation/resultLogo2.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  55. "Url=/static/ala/weather_app/wa_weather_app_header_icon.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  56. "Url=/static/ala/weather_app/3.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  57. "Url=/static/ala/weather_app/7.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  58. "Url=/static/ala/weather_app/8.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  59. "Url=/static/ala/ui/foot/ala_icon.gif", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  60. "Url=/static/search/touch.gif", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  61. "Url=http://wap.baidu.com/static/freeapp/search/star01.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  62. "Url=/static/tj.gif?wise_app_ex_deg=0&wise_app_ex_type=4&wise_app_ex_order=6&da=1357630296", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  63. "Url=http://opendata.baidu.com/weatherSubscribe/getWeather?srcid=13269&wd=%E4%B8%8A%E6%B5%B7%E5%A4%A9%E6%B0%94&cb=wa_weather_app_jcb1357630301880", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  64. "Url=http://a.m.baidu.com/rtstatic/index?&module=se&session=baiduapp&item=show", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  65. "Url=http://wap.baidu.com/static/freeapp/search/star03.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  66. LAST);
  67.  
  68. web_add_cookie("lsv=2012122801; DOMAIN=m.baidu.com");
  69.  
  70. web_url("tc",
  71. "URL=http://m.baidu.com/tc?tcreq4log=1&clk_type=1&vit=osres&l=1&w=0_10_%E5%A4%A9%E6%B0%94&t=iphone&ref=www_iphone&from=1269a&ssid=0&uid=E3069D4BD4613DEE9DEA2B5623E37775&lid=10632124265246805627&bd_page_type=1&pu=sz%401320_1001%2Cusm%403&fm=alop&order=1&ala_clk=3yT_1_0_10_b1&ala_mon=3yT_1_0_10_f_1357630301695_1357630303608&src=http%3A%2F%2Fm.weathercn.com%2F%3Fcid%3D01012601&ala_clk_t=%E6%9B%B4%E6%8D%A2&sec=1357630303608",
  72. "Resource=0",
  73. "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=",
  74. "Snapshot=t9.inf",
  75. "Mode=HTML",
  76. EXTRARES,
  77. "Url=/static/ala/ui/city/city-3.js", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  78. "Url=/static/ala/ui/city/p_w_picpaths/sprite.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  79. "Url=/static/ala/ui/city/p_w_picpaths/loading.gif", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  80. LAST);
  81.  
  82. web_submit_data("sdk.php",
  83. "Action=http://loc.map.baidu.com/sdk.php",
  84. "Method=POST",
  85. "RecContentType=text/plain",
  86. "Referer=",
  87. "Snapshot=t11.inf",
  88. "Mode=HTML",
  89. ITEMDATA,
  90. /* "Name=bloc", "Value=4anu-KXsr6yu9fL8t_a-9-u8v6Hp4-jo8bDo3qK5r7LBhNW6ltfd04bW0t_b1dLTyZuc256WiMDDxZTdwdiUkLSxpbG7vrn84rm_uL22_rHk-fquq-aor66juPKh__b1l9vJ2ZSZn5aPlZ2YntqQmp6Mh4CPnMzP2NfZj93K09Fxfnx_ISUhbnQuKysnI2wgNmt7MjQ-cjE4MGV1OGtsf0EUXQ5fWEJTFQILAxlbFQYLFx1bFBdBRUFEFBdFFBMXNTNpMDM9Km0xPElFKzQkbmtyCHN5aHN0cyJyZ2Iyf3cJFlcUDyqsddj.|tp=3", ENDITEM, */
  91. "Name=bloc","value=??'",ENDITEM,
  92. LAST);
  93.  
  94. web_url("tc_2",
  95. "URL=http://m.baidu.com/tc?tcreq4log=1&clk_type=1&vit=osres&l=1&w=0_10_%E5%A4%A9%E6%B0%94&t=iphone&ref=www_iphone&from=1269a&ssid=0&uid=E3069D4BD4613DEE9DEA2B5623E37775&lid=10632124265246805627&bd_page_type=1&pu=sz%401320_1001%2Cusm%403&ala_mon=Wg_3_0_10_l_1357630301892_1357630301937%7C3yT_1_0_10_l_1357630301695_1357630301889&src=m.baidu.com&sec=1357630305129",
  96. "Resource=0",
  97. "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=",
  98. "Snapshot=t10.inf",
  99. "Mode=HTML",
  100. EXTRARES,
  101. "Url=http://miserupdate.aliyun.com/data/brfversion.xml", "Referer=", ENDITEM,
  102. "Url=http://miserupdate.aliyun.com/data/brf.dat", "Referer=", ENDITEM,
  103. LAST);
  104.  
  105.  
  106.  
  107. web_url("tc_3",
  108. "URL=http://m.baidu.com/tc?tcreq4log=1&clk_type=1&vit=osres&l=1&w=0_10_%E5%A4%A9%E6%B0%94&t=iphone&ref=www_iphone&from=1269a&ssid=0&uid=E3069D4BD4613DEE9DEA2B5623E37775&lid=10632124265246805627&bd_page_type=1&pu=sz%401320_1001%2Cusm%403&fm=alop&order=1&ala_clk=3yT_1_0_10_b1&src=http%3A%2F%2Fm.weathercn.com%2F%3Fcid%3D01012601&ala_clk_t=%E6%9B%B4%E6%8D%A2&sec=1357630335810",
  109. "Resource=0",
  110. "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=",
  111. "Snapshot=t12.inf",
  112. "Mode=HTML",
  113. EXTRARES,
  114. "Url=http://opendata.baidu.com/weatherSubscribe/getWeather?srcid=13269&wd=%E6%AD%A6%E6%B1%89%E5%A4%A9%E6%B0%94&cb=wa_weather_app_jcb1357630339472", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
  115. LAST);
  116.  
  117. return 0;
  118. }</SPAN>

可以看出与我们传统录制的区别不是特别大。

但在这里需要注意两个问题:

1.可能会出现显示乱码问号的情况

这种情况网上说的很多其它办法可能都试过还不能解决,甚至是参数化显示正常,回话检查失败情况,先信誉度网上说的修改编码,最后还是不行就修改区域为中国就OK了。

2.通过IP筛选的时候,通常建议输入服务端地址,但这里没有通配功能,只能写准确地址,如果一个脚本中服务端有多个IP的时候再选择通过本地筛选。(具体wireshark可以看到每一个请求和应答报文)