Setting User Name and Password Values
At runtime, if the web server or web proxy requires NTLM or Basic Authentication, then this authentication is automatically handled, providing data dictionary values are set for the data items user
and password
.
There are several methods by which user and password values can be assigned, as explained below:
Unique values for every virtual user
Create a data table with columns names user and password.
Create a row for each virtual user (VU) containing the values as shown in the following example:
user,password
tom,gyug5g52
dick,jrkg5gk4g
harry,78gu645d
The table can be tab- or comma-delimited.
Assign this data source to any VU Groups running scripts that require authentication.
Single user and password for all users in a group
In-line data
Set values for user and password in the Global variables section of the Data tab for the test.
Data dictionary
In a Data Dictionary file assigned to multiple VU Groups.
Create data similar to the following:
user = mytestuser
password = yuiyui5ui45ui
Insert code in the script
You can explicitly set username and password values by using the following code:
- Java
- C#
this.getWebBrowser().setUserPassword("myuser", "mypassword");
or
this.getWebBrowser().setUserPassword(getString("user", "myuser"), getString("password", "mypassword"));
The more complex example extracts values for user and password from the VU data dictionary using getString()
, using the default values "myuser" and "mypassword" if the data dictionary doesn't include these values.
this.WebBrowser.SetUserPassword("myuser", "mypassword");
or
this.WebBrowser.SetUserPassword(GetString("user", "myuser"), GetString("password", "mypassword"));
The more complex example extracts values for user and password from the VU data dictionary using GetString()
, using the default values "myuser" and "mypassword" if the data dictionary doesn't include these values.
This code is automatically inserted in the script by the web script generator if the Server or proxy Authentication Required checkbox is selected on the Authentication tab of the Web Generation Options dialog box for a web script.