Dear Mr. Li: Perhaps a simple work-around for your problem would be to record the log-on sequence. I use Badboy to record series of HTTP requests, because I was not able to get the JMeter HTTP proxy recorder to record. (Other users have succeeded with it, though.) Badboy includes a web browser and can display web pages.
1. Download Badboy from www.badboy.com.au. 2. Use Badboy to navigate to your log on page. 3. Specify a user name and password, and log on. 4. Save the Badboy script (just in case). 5. Export the script to JMeter, creating a JMeter test plan. 6. Use JMeter to open the exported test plan. 7. Click on the last HTTP Request element and check the Send Parameters. If you see parameters whose values are the user name and password, you have created a one-user test for logging on. The next thing you will need to do for load testing is to learn to parameterize: create variables for the user name and password. (The JMeter user manual and FAQ can be helpful here.) JMeter offers different ways to do this. In my opinion: a. To always use the same user name and password: Create a User Defined Variables element and put it before and above the Thread Group element. Define the user name and password variables there. b. To use a list of user names and passwords in the same order for each test run: Prepare a text file with user names and passwords in the desired order. Use the __StringFromFile function in the Send Parameters of the HTTP Request to read the user names and passwords. c. (My favorite) To use a group of user names and passwords at random: choose a regular naming pattern for user names, such as "user1", "user2", "user3", and so on. Use the same string for the password: user1's password is "user1". Define a User Parameters element that constructs the user names from the base string ("user") and a number generated by the __Random function. The following topic from my test department's internal documentation describes the technique. The example describes how to construct account numbers, but you can adapt the instructions to construct user names and passwords. You probably will not need the left-padding with zeros to construct user names. By the way, if you work in the Windows world as I do, remember that JMeter names are case-sensitive! JMeter will treat "${Password}" and "${password}" as different variables. ------------------ Selecting strings at random from large set (JMeter) Updated: 11/4/2004 Problem You want to randomly contruct strings from a set of strings that vary by a regular pattern. The constructed string must include a number left-padded with zeros. A typical example would be bank account numbers. Solution The advantages of using the __javaScript and __Random functions to construct strings rather than using the _StringFromFile function to read strings from an input file are: · You do not need to create an input file of strings. · Each constructed string can be, in effect, a randomly selected string from a desired set of strings. Strings read from an input file by _StringFromFile are always selected by their order in the file. To demonstrate the solution, assume that you want to randomly select account numbers from a set of strings that follow this pattern: · Each account number begins with the same base string. · Each account number ends with a three-digit number in the range 1-100, left-padded with zeros. Steps To randomly select account numbers that follow the desired pattern, follow these steps: 1. In the test plan, create a User Parameters element. 2. Select this checkbox: "Update Once Per Iteration". 3. Define these user parameters: ----------- Name User1 ----------- RandomNumber ${__Random(1,100,ReuseRandomNumber)} Head 57111020 Tail ${__javaScript('000' + '${RandomNumber}',Dummy1)} AccountNumber ${Head}${__javaScript('${Tail}'.substring('${Tail}'.length-3\,'${Tail}'.length),Dummy2)} ----------- Note The number of zeros in the Tail parameter must match the subtracted number in the AccountNumber parameter: "length-X". Note Only the RandomNumber variable must be in a User Parameters element with a selected "Update Once Per Iteration" check box. The other variables can be in a User Parameters element with a cleared "Update Once Per Iteration" check box. However, it is most efficient to have all variables in a User Parameters element with the selected check box. 4. Reference ${AccountNumber} in appropriate HTTP Request elements. ------------------ Sincerely yours, Kyle McAbee -----Original Message----- From: Li, Charles [mailto:[EMAIL PROTECTED] Sent: Monday, November 15, 2004 10:31 AM To: JMeter Users List; Peter Lin Subject: RE: how to pass in username and password for load testing? How can I tell? The login page has fields for me to enter username and password. Thanks, Charles Li This is the source of the page: +++++++++++++++++++++++++++++++++++ <html lang="en"> <HEAD> <TITLE>OTN WebStore Login Page</TITLE> <LINK rel="stylesheet" href="includes/styles.css" type= "text/css"> <!-- To prevent caching --> <SCRIPT> function submitForm() { var frm = document.login; // Check if all the required fields have been entered by the user before // submitting the form if( frm.j_username.value == "" ) { alert("Please enter your Username"); frm.j_username.focus(); return ; } if( frm.j_password.value == "" ) { alert("Please enter your password"); frm.j_password.focus(); return ; } frm.submit(); } </SCRIPT> </HEAD> <BODY> <FORM name="login" action="j_security_check" METHOD=POST> <TABLE border="0" cellspacing="0" cellpadding="0" width= "100%" valign="top"> <TR> <TD><img src="images/vsmLogo.gif" border="0"></TD> </TABLE> <TABLE width="100%" border="0" cellspacing="0" cellpadding= "1" bgcolor="white"> <TR bgcolor="#838357"> <TD align="left" width="76%"> <A href= "main.do?login=true" class="WhiteText">Home</A></TD> </TR> <TR bgcolor="#DFDFBF"> <TD width="76%" class="BlueText"> Welcome to OTN WebStore </TD> </TR> </TABLE> <TABLE width="100%" border="0" cellspacing="0" cellpadding= "1" bgcolor="white"> <!-- <TR> <TD align="right" class="SubHeading">Sign in with your username and password to continue </TD> </TR> --> <TR> <TD width="70%" valign="top"> <P> </P> <BLOCKQUOTE> <P class="BlueBold"> New to OTN WebStore ?</P> <P class="BlackText"><A href= "registration.do?command=displayForm" class="Link"> Sign Up Now</A> to enjoy unrivalled online shopping experience</P> </BLOCKQUOTE> <DIV style="margin-left: 4em"> <BLOCKQUOTE> <P class="BlueText">At OTN WebStore you will find</P> </BLOCKQUOTE> <UL class="BlackText"> <LI>What you need. Fast.</LI> <LI>Exceptional choice.</LI> <LI>Great deals.</LI> </UL> </DIV> </TD> <TD width="30%" valign="top"> <TABLE width="100%" border="0" cellspacing="0" cellpadding="1" bgcolor="#B3B18E"> <TR> <TD align="top"> <TABLE width="100%" bgcolor="#F0F0E6" border="0" cellspacing="0" cellpadding="3" height="128"> <TR> <TD> <CENTER> <B class="bluebold"><FONT size= "+1">Existing WebStore Users</FONT></B><BR> <FONT size="-1">Enter your username/ password here</FONT> </CENTER> <br> <TABLE width="100%" border="0" cellspacing= "0" cellpadding="5"> <TR align="center"> <TD align="right" class="Prompt"> User Name</TD> <TD align="left"> <INPUT type="text" name="j_username" maxlength=20> </TD> </TR> <TR align="center"> <TD align="right" class="Prompt"> Password</TD> <TD align="left"> <INPUT type="password" name="j_password" maxlength=20 > </TD> </TR> </TABLE> <BR> <CENTER> <A HREF="javascript:submitForm()"><img src="images/buttons/signup.gif" border="0"></A> <br> <A href="notifypasswordform.do" class="HeaderLink">Forgot your password? Click here to proceed</A> <P><A href="changepasswordform.do" class="HeaderLink">Change your password? Click here to proceed</A></P> </CENTER> </TD> </TR> </TABLE> </TD> </TR> </TABLE> </TD> </TR> </TABLE> </FORM> <IMG src="images/line.gif" width="100%" height="12"> <TABLE width="100%" border="0" cellspacing="0" cellpadding="1" bgcolor="white"> <TR> <TD align="left"><FONT face="Verdana, Arial, Helvetica, sans-serif" size="-2"> Number of visitors:4</FONT> </TD> <TD align="center"><FONT face="Verdana, Arial, Helvetica, sans-serif" size="-2"> <A href="guestbook.do" class="HeaderLink">Questions, Comments, Suggestions ? Let us know your views through guest book</A>.</FONT> </TD> <TD align="right" class="BlackSmall"><A href="terms.do" class="HeaderLink"> Terms of Use</A></TD> </TR> </TABLE> <br> <b><FONT face="Verdana, Arial, Helvetica, sans-serif" size="-2"> Powered by <font color="red" size="-2"><i>Oracle Application Server Containers for J2EE 10g (9.0.4.1.0)</i></font></font></b> </BODY> </html> +++++++++++++++++++++++++++++++++++ -----Original Message----- From: Peter Lin [mailto:[EMAIL PROTECTED] Sent: Monday, November 15, 2004 10:27 AM To: JMeter Users List Subject: Re: how to pass in username and password for load testing? is the authentication form based or http protcol based. in other words. is the username passed as request parameters, or basic authentication? peter On Mon, 15 Nov 2004 10:24:42 -0500, Li, Charles <[EMAIL PROTECTED]> wrote: > I have a sample application that I want to use for load test with JMeter. > How do I pass in username and password to test pages that are protected by > authentication? > > In the source, I have the following: > ==================================== > if( frm.j_username.value == "" ) { > alert("Please enter your Username"); > frm.j_username.focus(); > return ; > } > > if( frm.j_password.value == "" ) { > alert("Please enter your password"); > frm.j_password.focus(); > return ; > ==================================== > > I added the following parameter: > frm.j_username.value=electowner > frm.j_password.value=welcome > > But, first I want to test that it actually reads the username and password, > so I did this: > > I try it on the browser and it did not read the username and password. > (http://server:port/vsm/authownerhome.do?frm.j_username.value=electowner&frm. > j_password.value=welcome) > > How should I pass in the username and password? > > Thanks, > Charles Li > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]