Professional Documents
Culture Documents
The Send Parameter with request in search sample looks like below picture. The variable name for search query is q and value is Jmeter. We will parameterize that value from an external file for two persons.
2. Now to generalize the value for parameter q we have to get values from data.xml file. The search queries put in the data.xml file are proxy and Blogs. Copy the contents the contents of the below two files in a note pad and save them as data.xml and sample.dtd in bin directory. data.xml <?xml version=1.0?> <!DOCTYPE allthreads SYSTEM sample.dtd> <allthreads> <thread> <parameter> <paramname>q</paramname> <paramvalue>Proxy</paramvalue> </parameter> </thread> <thread> <parameter> <paramname>q</paramname> <paramvalue>Blogs</paramvalue> </parameter> </thread> </allthreads>
sample.dtd <!ELEMENT allthreads (thread+)> <!ELEMENT thread (parameter+)> <!ELEMENT parameter (paramname,paramvalue) > <!ELEMENT paramname (#PCDATA) > <!ELEMENT paramvalue (#PCDATA) >
3. Add HTTP User parameter modifier to search sample. (Add->preprocessor->HTTP User parameter modifier).In that element change the File Name value to data.xml (the default file is users.xml).
4. In Search sample replace the value of parameter q with *. Make sure to give number of threads (users) to 2 in Thread Group.
5. Now run the test. In view results tree the response data will be shown. See the result of search response in Render HTML view. The values have been passed from the file.
3. Select the Login sample and add a User Parameter element to it. Add->Preprocessor-> User parameters
__CSVRead is a function which reads values from file test.csv . The second parameter of the function is the column number .Name is the variable name which is referenced in the request sample.
Now select the login sample and change the values of userid and password to ${A} and ${B}.
You can also generate the value for variable using function helper dialog. Open it from options or use shortcuts ctr+F. Choose __CSVRead from choose a function dropdown list. The value field of first row in the Function parameters represents the file name (here test.csv) and second row represents column number (e.g. 0, 1, 2). Now run the script and observe the result in view result tree.
We will parameterize the search keyword Jmeter. 2. Now add a CSV Data set Config and a Listener element to the thread group. Add->Config Element->CSV Data Set Config Add->Listener->View Results Tree 3. Now open a notepad (inside bin) and enter your keywords.
Save the file as search.csv. The extension csv makes it a comma separated Value (CSV) file.
4. Now select the CSV Data set Config element and fill in the fields as follows Filename: search.csv (Give the path name if you have put it inside a subfolder e.g. foldername\search.csv) Variable Names: A (This variable name is referenced in the search sample.) Delimiter: ,
5. Now go to search sample and change the value of variable q to ${A}.In Jmeter we reference a variable using ${} .For each iteration the value of q will be replaced as fetched by variable A.
6. Now go to thread group and make the number of threads (users) to 3. 7. Run the script(ctr+R) and observe the result in result tree.