天天看点

LoadRunner levels of integration with web pages

<a href="http://blog.51cto.com/attachment/201203/163805662.png" target="_blank"></a>

As you can see between user and web server there are mainly 2 layers:

Layer 1 is where user interacts with the browser by e.g. clicking a button, selecting values from the list or submitting a form

Layer 2 is where browser communicates with web server which includes:

creating and sending HTTP requests to the web server based on user&amp;rsquo;s actions

receiving HTTP responses from the web server

rendering HTTP responses, forming an UI and displaying it to the user

Below I&amp;rsquo;m providing two scripts that do exactly the same thing but in slightly different way. The goal for each script is to search for a &amp;ldquo;linux&amp;rdquo; word using google search.

First, lets look at &amp;ldquo;Web (HTTP/HTML)&amp;rdquo; type of the script:

Action()

{

        web_url("www.google.com",

                "URL=http://www.google.com/",

                "Resource=0",

                "RecContentType=text/html",

                "Referer=",

                "Snapshot=t1.inf",

                "Mode=HTML",

                LAST);

        lr_think_time(6);

        web_url("search",

                "URL=http://www.google.co.uk/search?hl=en&amp;source=hp&amp;q=linux&amp;btnG=Google+Search&amp;meta=&amp;aq=f&amp;oq=",

                "Referer=http://www.google.co.uk/",

                "Snapshot=t2.inf",

        return 0;

}

What happens here?

In line 3 we are entering google.com web site

In line 14 we are sending HTTP request that browser would generate after searching for value &amp;ldquo;linux&amp;rdquo;

Now, lets look at &amp;ldquo;Web (Click and Script)&amp;rdquo; type of the script:

        web_browser("www.google.com",

                DESCRIPTION,

                ACTION,

                "Navigate=http://www.google.com/",

        web_edit_field("q",

                "Type=text",

                "Name=q",

                "SetValue=linux",

        web_button("INPUT",

                "Type=submit",

                "Tag=INPUT",

                "ID=",

                "Value=Google Search",

                "UserAction=Click",

In line 4 we are entering google.com web site

In line 10 we are typing value &amp;ldquo;linux&amp;rdquo; into the input field

In line 19 we are clicking &amp;ldquo;Google Search&amp;rdquo; button that will move us to the page with search results

So what is the difference between these two scripts?

First script operates on much lover level comparing to second script. It deals with HTTP requests without taking care about what actions user actually performs. It doesn&amp;rsquo;t care how fast user&amp;rsquo;s browser renders and display the UI. It only checks how fast web server is able to response with correct message.

Second script operates only on UI level without taking care what happens underneath. Response time here includes not only time needed to send/receive HTTP traffic but also time needed to form/display UI to the user.

Basically second script approach is less error prone because you don&amp;rsquo;t have to deal with low level things like HTTP parameters. And You are replicating user&amp;rsquo;s actions in a natural way.

So if you need to choose, then I would recommend Web Click and Script type of the script.

本文转自 小强测试帮 51CTO博客,原文链接:http://blog.51cto.com/xqtesting/808764,如需转载请自行联系原作者

继续阅读