Tips for browser emulation in network-level scripts

Different browsers can have a dramatic effect on a web application’s performance. In order to accurately test an application’s performance, it is important to emulate different browsers to understand how the application’s behavior and network utilization are affected.  Here are some helpful tips to maximize your efforts.

When using a UI level script, such as TruClient, the browser is fully emulated. This can affect the performance test as follows:

  1. Real page rendering is performed, and uses the exact same method as the emulated browser. This may include HTML, CSS, images and more. It takes time that is not spent in a network-level script.
  2. The actual cache logic for the selected browser is used.
  3. The actual proxy logic for the selected browser is used.
  4. The actual User-Agent for the selected browser is used.
  5. Connection behavior, such as connection limit and keep-alive timing, is determined by the actual browser.

When using a network-level script, such as Web (HTTP/HTML), no actual browser is used. However, different browsers can and should be emulated to correctly simulate the load on the application under test (AUT).        

The most common (and simplest) way of emulating different browsers in network-level scripts is by sending different User-Agent headers. The User-Agent header is sent to let the AUT know what browser, version and locale sent the request. Different User-Agent headers can affect the AUT’s behavior as follows:

 

  1. The AUT may use different server logic for different browsers, which can cause different response times.
  2. The AUT may send different responses to different agents. For example, modern applications often try to send a mobile-compatible version of the pages to mobile agents.
    1. The mobile-compatible version might use lower-resolution media to save bandwidth.
    2. The mobile-compatible version might return only a subset of the content, in order to reduce the download size.
  3. The AUT may have different connection limits, keep-alive limits, etc. for different agents.

 

The result, from a performance engineer perspective, is that the AUT experiences a different load when accessed by different User-Agents.

You can determine the User-Agent header used by the script during replay from the Run-time Settings dialog, in the Browser -> Browser Emulation -> User Agent option.

Another way to emulate different browsers in network-level scripts is to limit the number of concurrent connections used by the Virtual User for connecting to each host.

For example, IE6 uses two connections per host, while IE9 and Chrome both use six connections per host by default.

In LoadRunner, this can be emulated in the following ways:

  1. By default, a new Virtual User script will send the User-Agent header compatible with IE6.
  2. The first time a script is recorded, the User-Agent header sent by the recorded application will be added to the script runtime settings, to be used during replay.
  3. In the Run-Time Settings configuration, you may change the selected User-Agent string to emulate specific browsers, as described in the Run-Time Settings section of the LoadRunner User Guide.
  4. While the script is replayed, the maximum number of connections per host is determined by the emulated browser. For example, the virtual user will use two connections when emulating IE6, and six connections when emulating IE9.
  5. In the script itself, you can call the web_set_sockets_option function to set a different connection limit. This will override the Run-time Setting for the browser.

You can emulate other aspects of browser behavior using the following advanced options and configurations:

  1. Configure a browser-specific cache behavior using the relevant options in the Run-time Settings dialog’s Browser -> Browser emulation -> Simulate browser cache option.
  2. Configure browser-specific proxy behavior using the relevant options in the Run-time Settings dialog’s Internet Protocol -> Proxy node.
  3. Turn DNS caching on or off, determine locale behavior, SSL behavior and more, in the Run-time Settings dialog’s Internet Protocol -> Preferences -> Set advanced options section.
  4. Use the many options available from the web_set_sockets_option function.

Many thanks to Oded Keret from LoadRunner R&D for providing the information for this post.

 

Let us know which browsers you emulate in your performance tests by leaving a comment below.

 

WebAndMobileTestingButton.jpg

Comments
NaveenKumar Namachivayam(anon) | ‎03-07-2013 11:24 AM

I used Safari, IE and Chrome User agent strings to test web apps.

 

Thank you!

Udhay | ‎03-09-2013 06:32 AM

While Mobile Page responses - there are appreciable changes in the response and the cache-logic.

Otherwise, do you really see good amount of differences?

hong yan wang(anon) | ‎05-29-2013 01:01 AM

I used Chrome and Firefox to test web  apps.

Kamatchi Sundar(anon) | ‎06-20-2013 04:31 AM

I executed a test in Controller 11.0. Please find the findings below,

 

When I selected the IE 8.0 browser in the browser emulation Run-time settings, it is still creating only 2 connections. We have verified after seeing connections graph during the test.

 

But when we explicitly set the connections count using web_set_sockets option("MAX_CONNECTIONS_PER_HOST","6"), we are able to see 6 connections in the graph.

 

Please let me know if selection of browser version from the run-time setting is not sufficient to emulate the browser type.

 

Please advise!

| ‎06-25-2013 04:51 AM

Hello Kamatchi,

 

The mentioned ability to determine the maximum number of connections according to user agent string was added in LoadRunner 11.50.

 

If you are using Controller from LoadRunner 11.0, you will have to configure number of connections using the web_set_sockets_option step.

 

Regards,

Amrita Shetty(anon) | ‎08-19-2014 06:04 AM

Hi,

 

How do we emulate the Network speed in the same manner i.e. either by adding headers in the script as its done for User-Agent for by adding any logic in the script.

I know we can emulate the Network speed through Run-Time Settings, but i need something at the script level.

Thanks

 

raj2014(anon) | ‎09-10-2014 03:17 PM

Hi Oded

 

I have a question related to web_concurrent_start function. If I have selected user Agent as Ie9 which will allow 6 connection per host but in web_concurrent_start I have 10 calls, means Loadrunner will submitted 10 calls together. What will happen in this scenario.

 

1. web_concurrent_start 10 connection override IE 6 connection OR

2. Only 6 connections will be made to host.

 

If option 1 is true then in script I should not have more than 6 calls under web_concurrent_start , if I am simulating IE9 browser.

 

Please share your opinion.

Leave a Comment

We encourage you to share your comments on this post. Comments are moderated and will be reviewed
and posted as promptly as possible during regular business hours

To ensure your comment is published, be sure to follow the Community Guidelines.

Be sure to enter a unique name. You can't reuse a name that's already in use.
Be sure to enter a unique email address. You can't reuse an email address that's already in use.
Type the characters you see in the picture above.Type the words you hear.
Search
Showing results for 
Search instead for 
Do you mean 
About the Author
Malcolm is a functional architect, focusing on best practices and methodologies across the software development lifecycle.
Featured


Follow Us
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.