5

I am new to JMeter and I want to learn how to login to a website using JMeter. So I selected Flipkart site for creating my first test. The steps which I have followed are mentioned below:-

  1. Created a Test Plan
  2. Created a Thread Group with
    • No of Threads = 1
    • Ramp-up Period = 1
    • Loop Count = 1
  3. Used HTTP Cache Manager:
    • Checked the option 'Use a Cache-Control/Expires Header when processing GET requests'
    • Max Number of Elements in cache = 5000
  4. Used HTTP Request Defaults:
    • Server name = www.flipkart.com
  5. Used HTTP Cookie Manager:
    • Checked the option 'Clear Cookies each iteration?'
    • Cookie Policy = compatibility and
    • Implementation = HC3CookieHandler
  6. HTTP Request:
    • Path = /
    • Method = GET
    • Parameters(added) = username :: [email protected] and password :: *****
  7. Listeners used are 'Summary Report' and 'View Results Tree'
  8. Used Response Assertion with following configuration:
    • Apply to: Main sample and sub-samples
    • Response field to Test = Text Response
    • Pattern Matching Rules = Contains
    • Patterns to Test (added): Hi xxx@g!
      1. After adding all these elements and configuring the same as mentioned above, I executed the script.

After execution:

  1. It shows a result in Response Assertion = Assertion error: false and Assertion failure: true, Assertion failure message: Test failed: text expected to contain /Hi xxx@g!/

Please let me know where I have made mistake(s), as I am unable to proceed further with JMeter.

Thanks

5 Answers 5

9

Although you can do it directly with Jmeter but as you mentioned above there is so much that you will have to do for it and you will require to have strong knowledge of Java & Jmeter.

OR

You can do it the easy way. Use Blazemeter.

Blazemeter has a Chrome extension using which you can record user actions in Chrome and then export the test script. Those script can then be used in Jmeter. And the good part is that it will record everything, the login, other form data cookies, etc.

2
  • Unfortunately, the blazemeter website doesnt say what it actually is. Is it free? is it a service which runs jmeter? Is it a replacement for jmeter? Is it free tools which can be used with jmeter? Jul 22, 2020 at 12:08
  • Yes, the extension for Chrome is free. Sep 14, 2022 at 5:44
3

If you just started with JMeter, then I will suggest you to first go through this link https://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf

It will help you a lot in starting with JMeter.

Secondly, as you are new to JMeter, then you should go with the Recording option provided by JMeter, using that you will not need to add Sample Requests by your own and it will ease your work.

In addition to it, you should register yourself to 'Blazemeter' (registration is free) https://blazemeter.com/ and they will provide you 5 videos of JMeter, 1 video on 1 day and it will help you a lot in building your test plans and enhancing your knowledge of JMeter.

Lastly, you should create your tests on your organization applications, because most of the live running sites/application, doesn't allow requests from same IP and they block the same, just to avoid unwanted traffic (this may not be your case as you are using only 1 user), but still you should try creating your tests on your web-application.

These were the general issues, which you need to take care of. Now the issues which I see with your created plan are:-

  1. You have used the 'Cookie Manager' but not specified any cookie that is being used in your application (which is Flipkart in your case). Cookie Manager should contain the name and value of all the cookies being used, else you will not be able to login and maintain session after login.

Examples: Cookies like ASP.NETSessionID (for .Net applications), JSessionID (for Java application) and many more, depending upon your application under test.

  1. For login you have used only Username and Password in you request, but there can be other parameters too, which will be required for the successful login. They can be SessionID, ViewState, EventValidation etc. (again depending upon your application). Without these you will not be able to login. You can see all these parameters once you follow the recording process.

  2. Most of the times, applications uses some token keys like CSRF token, some Unique ID (which is generated on just hitting the base URL like 'flipkart.com') but is passed on to the subsequent requests for Authentication. For such unique IDs you will need to use the 'Regular Expression Extractor'

  3. Another reason for your script not be working is that, you are using single HTTPRequest with Path '/' and passing on Username and Password to this request, but as far as I know '/' is the request for the base URL and for passing on Username and Password, there will be some other POST request (like flipkart.com/login) which will use your credentials as parameters and then allow you to login (if Authentication is pass). Such requests too are missing from your test plan.

For the debugging purpose, you should validate your result in Tree Listener too (which you have already added), once you execute your script 'Response Data' tab of this listener will display the HTML response of your request, from there you can verify whether the response shown is of your application under test or not.

2

Looking into flipkart website:

  1. Method to perform login should be POST
  2. You need to pass a dynamic parameter along with username and password

Flipkart site

So you test plan should be amended as follows:

  1. HTTP Request
    • Method: GET
    • Path: /
  2. Regular Expression Extractor - to extract that FK from response and store it into JMeter Variable

  3. HTTP Request

    • Method: POST
    • Path: POST /account/loginWithoutOtp
    • Parameters:

      • contact_id: email
      • password: password
      • __FK: value from step 7 (it is likely that you need to tick "Encode" box as well)

See Using RegEx (Regular Expression Extractor) with JMeter guide for detailed information on one of the most popular ways of doing correlation in Apache JMeter

0


Please check this attached image.
enter image description here

enter image description here

I making some mistake to get the output. Can you explain me how to add RegEx in my TestPlan & please point out where have i went wrong. Thanks

2
  • if you want to add anything more to you question, you can add a comment below the answer given. Aug 3, 2015 at 14:40
  • I posted in 'Add Another Answer' workspace. Please see my previous post & help in resolve this test plan.
    – jacksantho
    Aug 4, 2015 at 4:53
0

Firstly its not a right move to performance test a live application. You can take performance test as equivalent to hacking. Live applications are made very much secure and usually it doesn't allows requests from proxy ip servers and have firewall issues. Bette you try scripting some demo applications for your learning purpose.. Now the second part if you are hell bent on recording flipkart using jmeter, install fiddler and see what requests are being sent while enabling the capture traffic tab of fiddler.. recording through jemeter might miss to capture few of the responses but with fiddler you can capture all the incoming and outgoing requests. Finally you need to add manually http requests in jmeter which are not there...

1
  • This might be more suitable as a comment (i know you are below the 50 at time of writing so cant add them yet) I think your comment is a bit general as an answer (and sadly hopeful!). Try to focus your answer more on answering the specific question.
    – ECiurleo
    Jan 28, 2016 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.