I have a load test that uses basic authorization for the user login .So I need to retrieve the information for username and password for n number of users and run a load test for all of them simultaneously.I am able to retireve it for one and run it but failed to change the info for different users and put it back again in the requestheader.
Connection (2) has request (2) with Authorization = "Basic dm1xYTNcTG9hZDI6cGFzc3dvcmQ=" .This decodes as "vmqa3\Load1:password" where username is vmqa3\Load1 and password is "password".So how can I change it in my script for "n" number of users .The value needs to be changed like Load1,Load2..... etc n times and to load it back in the request body different for each user.
For example for user2 i.e i.e Load2,it should be vmqa3\Load2:password and decoded form is "dm1xYTNMb2FkMTpwYXNzd29yZA=="
My script is like this.I tried it for two users but right now it is not changing the authorization in the request body to have different username information.It is just signing with the same information as "vmqa3\Load1:password".
Please help me find what is wrong with the script and how can I change the info and pass it differently for each user.
var VirtualUsers, TestInst, i, TaskVar, request,Load;
VirtualUsers = new Array();
Logins = new Array();
// Creates a new load test
TestInst = LoadTesting.CreateTestInstance("TestInstance4");
for(i = 1; i<=2; i++)
// Obtains the task
TaskVar = LoadTesting.HTTPTask("Task8");
TaskVar.TargetServer = "vmqa3:80";
// Creates a virtual user and specifies the task and test for it
VirtualUsers = LoadTesting.CreateVirtualUser("VirtualUser" + aqConvert.VarToStr(i));
VirtualUsers.Task = TaskVar;
VirtualUsers.Group = TestInst;
// Modifies the request variable
request = TaskVar.Connection(2).Request(2);
header = TaskVar.Connection(2).Request(2).RequestHeader;
headerArray = header.split("\r\n");
accountAndPassword = headerArray;
//decodedAccountAndPassword = decode64(accountAndPassword.substring(21, 500));
//Log.Message ("account=" + decodedAccountAndPassword);
//account = decodedAccountAndPassword.split(":");
//password = decodedAccountAndPassword.split(":");
//Log.Message("account=" + account);
//Log.Message("password=" + password);
headerArray = encode64("vmqa3\Load" + i + ":password");
header = "Basic" + headerArray;
// Runs the task
TestComplete provides built-in support for Basic authentication, and therefore, you do not need to process the information in your script. To learn how to specify login information for Basic authentication, please see the "Supported Authentication Types" help topic.
The help files say like this :
Basic authentication - The browser displays a dialog box where the user enters his or her user name and password (which are also called credentials). The password is passed to the Web server as Base64 encoded clear text, which means that this password might be intercepted, decoded and reused. This authentication method is fully supported by TestComplete.
I tried to do in the script by decoding and encoding the login info . Also if we want to run the script against 100 users,do I need to enter username,password information for all the 100 users in the authentication information grid. Can it not be done with the script that I have ?
TestComplete uses the same login information for all virtual users. Could you please tell us why different login information is neded for your test? Are you going to create 100 Windows accounts for your virtual users?
Currently, TestComplete can use only a single login/password combination for all virtual users. However, I've registered your request as a suggestion in our DB.
how will TC use these different usernames and passwords for login.
When you specify a login/password for a server name and domain, TestComplete will always use the login and password for all virtual users which work with the server located in the domain. If the test works with different servers, you may need to specify another login/password/server/domain combination.
The built-in features of TestComplete allow specifying only a single login/password combination per domain/server. However, it looks like your script overrides TestComplete's behavior, and as a result, different users use different login data (encoded by your script).