HPE Software is now Micro Focus
HPE Software is now Micro Focus
LoadRunner and Performance Center
cancel

How to record and enhance the browser’s native login prompt in TruClient

How to record and enhance the browser’s native login prompt in TruClient

hilale

Guest post by Asaf Alster from TruClient, Performance Engineering Core R&D team

About this post

When creating performance tests, test engineers want to accurately simulate real-world scenarios where multiple users access the same server and authenticate with different credentials. This post explains how to do so using TruClient. TruClient is a tool for creating scripts that can then be used in load testing or monitoring Web applications. You can find more information about TruClient in the TruClient Help Center.

 (Note: This post is intended for users that have a basic knowledge of using TruClient.)

 Preface

HTTP has supported multiple authentication forms since its early days; one of them is basic access authentication. HTTP Basic authentication (BA) is a simple technique in which standard fields in HTTP headers are used for enforcing access control. When using this method, there is no need to use cookies, session identifiers, or even login pages.1

All browsers supported by TruClient (Chrome, Chromium, Firefox, and Internet Explorer) have built-in support for BA using a native login prompt. TruClient identifies when the authentication dialog is opened by the browser, it and records the input entered by the script developer to a dedicated step. During the script replay process, TruClient identifies the authentication prompts, and inputs the recorded data into the appropriate fields.

Here are examples of authentication dialogs as they appear in browsers supported by TruClient:Authentication required.PNG

 Let’s see how TruClient’s advanced parameters mechanism simulates real-world conditions in which multiple users authenticate with different credentials.

Record the Authentication

1. Record your business flow, including navigating to a server that requires authentication.

2. When prompted for credentials, enter the username (including the domain) and password, and click OK.

 Note: When recording a script using a Chromium or Internet Explorer browser, TruClient replaces the standard authentication dialog with a proprietary dialog. While these dialogs look different, they behave the same and are recorded as expected.Authentication Dialog 2.PNG

 

 3. After authentication, two steps are created: “Navigate…” and “Enter credentials…”.

Note: The “Enter credentials…” step can also be added manually. For details, see Adding authentication dialog steps manually section later in this post.

Chromium – Recorded stepsChromium – Recorded steps

Firefox  – Recorded steps (“Navigate“ and “Authetication dialog” steps are grouped automatically)Firefox – Recorded steps (“Navigate“ and “Authetication dialog” steps are grouped automatically)

Internet Explorer  – Recorded steps  (“Navigate“ and “Authetication dialog” steps are grouped automatically)Internet Explorer – Recorded steps (“Navigate“ and “Authetication dialog” steps are grouped automatically)

4. Expand the Authentication dialog (“Enter credentials…”) step. You can see the typical TruClient step structure which contains a Step, Arguments, and Transactions

 

TruClient “Authetication dialog” stepTruClient “Authetication dialog” step

5. The Step section contains the selected “Dialog - Authenticate” action, as well as other step settings that are not addressed in this post. For more information, see the TruClient Help Center.TruClient “Authentication dialog” step – Step sectionTruClient “Authentication dialog” step – Step section

 6. The Arguments section contains the credentials and domain that were entered.TruClient “Authetication dialog” step – Arguments sectionTruClient “Authetication dialog” step – Arguments section

When the Username is entered in the format [Domain]\[Username], TruClient splits the values between the Username argument and the Domain argument.

Note: During replay, if the Domain value exists, TruClient concatenates the Username and the Domain arguments using the format [Domain]\[User Name].

The Button argument represents the button on which to press in the Authentication dialog. Available options are OK (default) and Cancel.

7. You can now replay the script with the recorded arguments.

 Parametrize the authentication dialog - best practice

Now we will demonstrate how to parametrize the Username argument. This enables you to use different values for different running users.

1. Expand the step Arguments section, and change the input mode of the Username argument to Parameter.TruClient “Authetication dialog” step – Username argument set for parameter inputTruClient “Authetication dialog” step – Username argument set for parameter input

 2. Highlight the argument text, and right-click it to open the context menu.

3. In the context menu, select Create New parameter from Selection…

 

TruClient “Authetication dialog” step – Context menu showing relevant options for selected textTruClient “Authetication dialog” step – Context menu showing relevant options for selected text

4. In the Enter Parameter Name dialog, enter a name for the new parameter to use in the Username argument field.TruClient “Enter Parameter Dialog”TruClient “Enter Parameter Dialog”

 5. Click OK to approve parameter creation. After the dialog closes, you should see the following:

  • The selected text is replaced with the parameter name as the input of the Username argument.TruClient “Authetication dialog” step – Parameter name replaced the Username argument text valueTruClient “Authetication dialog” step – Parameter name replaced the Username argument text value
    • A parameter with the name “Username” is added to the Parameters List dialog.
    • When using VuGen, you can open the Parameter List dialog from the Solution Explorer by clicking on the ParametersVuGen -  Solution ExplorerVuGen - Solution Explorer

       

      VuGen Parameters dialogVuGen Parameters dialog

       

7. Repeat the above steps for the Password and Domain arguments (making adjustments as necessary).

Note: Since we configured a couple of different parameters for the Authentication dialog, we would like to correlate their value’s selection. To do so, the parameters must use the same configuration for the Select next row and Update value one settings.

For more information on configuring parameters, see the VuGen Help Center.

Adding authentication dialog steps manually

All the various steps that are created by TruClient during recording can also be added manually to the script using TruClient Toolbox.

1. Open the TruClient Toolbox, and drag the Generic Browser Action step into the script.TruClient ToolboxTruClient Toolbox

 2. Unfold the step, and expand the Step

3. Change the selected Action to “Dialog – Authenticate”.Generic Browser Action step – Step sectionGeneric Browser Action step – Step section

 4. Expand the Arguments section, and enter the appropriate value.

Note: During replay, if the Domain value exists, TruClient concatenates the Username and the Domain arguments using the format [Domain]\[Username].

5. The Button argument represents the button on which to press in the Authentication dialog. Available options are OK (default) and Cancel.TruClient “Authetication dialog” step – Arguments sectionTruClient “Authetication dialog” step – Arguments section

 6. During replay, if the manually added step is positioned in the proper location in the script, it will identify an opened authentication dialog, and will act on it.

Summary

In this post, we have shown how to use TruClient to handle authentication dialogs to simulate real-world scenarios, where multiple user credentials are used for the authentication stage. TruClient records the authentication dialogs, which you can then enhance in the recorded script. Using parametrization to vary arguments enables you to build robust and random scripts, which are a best practice of load testing.

Get started with Micro Focus LoadRunner with a free trial today.

Troubleshooting

Problem: The authentication dialog does not appear during recording. This is possibly a result of a combination of the following:

  1. Custom Internet Explorer browser settings
  2. Web site with NTLM Authentication
  3. Domain account

Possible Solution: Use a non-domain user for the Windows login during script recording.

Make sure you also use a non-domain user for Windows login on the Load Generators.

 

References and Notes

  1. "RFC 1945 Section 11. Access Authentication". IETF. May 1996. p. 46. Retrieved 3 February2017.

 

 

 

 

  • Load Testing
About the Author

hilale