Reprint: http://www.51testing.com/html/09/n-838009.html
LoadRunner's Virtual User Generator provides a human script recording feature, which greatly reduces the scripting threshold for beginners, LoadRunner provides two ways to record scripts: html_based Script and url-based script, beginners wonder what is the difference between these two ways? Let's do a simple analysis here.
Let's go through the two ways to record Baidu home page, compare how they are different from each other.
HTML-style script:
Action () {Web_url ("www.baidu.com", "url=http://www.baidu.com/", "resource=0", "Reccontenttype=text /html "," referer= "," Snapshot=t3.inf "," mode=html ", Extrares," url=http://s1.bdstatic.c Om/r/www/img/i-1.0.0.png ", Enditem," Url=http://s1.bdstatic.com/r/www/img/bg-1.0.0.gif ", ENDITEM," Url=/favi Con.ico "," referer= ", Enditem," url=http://suggestion.baidu.com/su?wd=&cb=window.bdsug.sugprerequest&sid= 1440_2031_1945_1788&t=1362056239875 ", Enditem," url=http://suggestion.baidu.com/su?wd=%e8%99%ab%e5%b8%88 &p=3&cb=window.bdsug.sug&sid=1440_2031_1945_1788&t=1362056247256 ", ENDITEM," Url=http:// suggestion.baidu.com/su?wd=%e8%99%ab%e5%b8%88%20&p=3&cb=window.bdsug.sug&sid=1440_2031_1945_1788 &t=1362056247969 ", Enditem," url=http://suggestion.baidu.com/su?wd=%e8%99%ab%e5%b8%88%20%e5%8d%9a%e5%ae%a2% e5%9b%ad&p=3&cb=window.bdsug.sug&sid=1440_2031_1945_1788&t=1362056251016 ", Enditem, last); return 0;}
URL-style script:
Action () {Web_url (www.baidu.com, "url=http://www.baidu.com/", "resource=0", "reccontenttype=text/h Tml "," referer= "," Snapshot=t67.inf "," Mode=http ", last); Web_concurrent_start (NULL); Web_url ("Shouye_b5486898c692066bd2cbaeda86d74448.gif", "Url=http://www.baidu.com/img/shouye_ B5486898c692066bd2cbaeda86d74448.gif "," resource=1 "," Reccontenttype=image/gif "," referer=http://www. " baidu.com/"," Snapshot=t68.inf ", last); Web_url ("Gs.gif", "Url=http://www.baidu.com/cache/global/img/gs.gif", "resource=1", "reccontenttype=i Mage/gif "," referer=http://www.baidu.com/"," Snapshot=t69.inf ", last); Web_url ("Tangram-1.3.4c1.0.js", "Url=http://s1.bdstatic.com/r/www/cache/global/js/tangram-1.3.4c1.0.js", "Re Source=1 "," Reccontenttype=application/javascript "," referer=http://www.baidu.com/"," snapshot=t71.in F ", last); Web_url ("Home-2.5.js", "Url=http://s1.bdstatic.com/r/www/cache/global/js/home-2.5.js", "Resource=1", "Reccontenttype=application/javascript", "referer=http://www.baidu.com/", "Snapshot=t72.inf", last) ; Web_url ("U-1.3.4.js", "Url=http://s1.bdstatic.com/r/www/cache/user/js/u-1.3.4.js", "resource=1", "Rec Contenttype=application/javascript "," referer=http://www.baidu.com/"," Snapshot=t73.inf ", last); Web_concurrent_end (NULL); Web_url ("I-1.0.0.png", "Url=http://s1.bdstatic.com/r/www/img/i-1.0.0.png", "resource=1", "RecContentT Ype=image/png "," referer=http://www.baidu.com/"," Snapshot=t70.inf ", last); Web_concurrent_start (NULL); Web_url ("su", "url=http://suggestion.baidu.com/su?wd=&cb=window.bdsug.sugprerequest&sid=1431_2031_1944_ 1788&t=1362056977341 "," resource=1 "," Reccontenttype=baiduapp/json "," Referer=http:www.baidu.com/"," Snapshot=t74.inf ", last); Web_url ("Favicon.ico", "Url=http://www.baidu.com/favicon.ico", "resource=1", "reccontenttype=image/x- Icon "," referer= "," Snapshot=t75.inf ", last); Web_concurrent_end (NULL); return 0;}
html_based script is the default mode of the LoadRunner, that is, the default mode, which is usually said high-level mode, generally prefer this mode of the mode of recording the script is relatively short, easy to read. It places a request for a page of a class in a web_url.
url-based script is commonly referred to as the low-level recording mode, this mode of recording the script is relatively long, is not conducive to reading, but the script is more intuitive, it sends the client to the server side of each request is placed in a separate web_url, that is, a request corresponding to a web_url, The page and the picture generate corresponding Web_url, relative to the html_based script mode to place the request of a page in a web_url way, the script of url-based scripts is more intuitive.
How do I tell which mode recording to use from my script?
We can differentiate from the value of "mode" in script Web_url, html_based the value "Html" in mode, and the value of mode in url-based script mode is "http". There is also html_based script mode recorded as Web_submit_form, while url-based script mode is recorded as Web_submit_data.
Comparison of the advantages of two recording methods:
(i) HTML recording
Pros: Reduces the need to capture dynamic values.
(1) The resource is removed from memory and downloaded during playback. As a result, scripts are much smaller and easier to read than other recording methods.
(2) because there are fewer hard-coded scripts, only fewer dynamic values need to be correlated.
(3) You can insert a statement such as a picture check to check if the result is correct.
(4) Because HTML mode playback requires active parsing of the returned information, it may be more resource-intensive than other recording modes. However, the HTML schema Record/replay has considerably improved, making the differences minimal and insignificant.
(5) The HMTL recording level produces a separate step for each HTML user action. and HTML-generated scripts are very concise and straightforward, and easy to read.
(ii) URL recording
Pros: Scripts are flexible and measurable.
(1) memory and cache are no longer searched during script playback.
(2) The script is more extensible. Supports Java applets and ActiveX objects on the page.
(3) The URL recording level records requests for each object on the server, recording them as a separate request. Better control of business processes.
How do I choose two modes?
1, browser-based applications recommend the use of html-based Script.
2. url-based Script is not recommended for browser-based applications.
3. If the browser-based application contains Java Script,applet and so on, and the script generates requests to the server, such as the paging button for the DataGrid, it is also recorded using the Url-based script method.
4. The HTTPS security protocol is used in browser-based applications and is recorded using url-based script mode.
5, the recording process do not use the browser "back" function, LoadRunner support for it is not very good.
Tips: During the script recording process, you can switch flexibly between the HTML level and the URL level as needed for best results.
LoadRunner techniques HTML and URL two recording mode analysis