如何在JMeter中实现多用户按顺序访问多个页面?
Got it, let’s break this down step by step—this is a super common use case and really straightforward once you understand how JMeter executes elements.
Step 1: Create a Thread Group for Your 5 Users
First, you need a Thread Group to represent your concurrent users:
- Right-click on your Test Plan → Add → Threads (Users) → Thread Group
- In the Thread Group settings:
- Set Number of Threads (users) to
5(this defines your 5 unique users) - Set Ramp-Up Period to
0if you want all 5 users to start at the same time, or adjust to a number like5if you want them to launch one per second - Set Loop Count to
1if each user only needs to go through the page sequence once; bump this up if you want them to repeat the flow multiple times
- Set Number of Threads (users) to
Step 2: Add HTTP Requests in Your Exact Sequence
JMeter runs elements top to bottom within a Thread Group, so just add your 4 page requests in the order you need:
- Homepage Request:
- Right-click on the Thread Group → Add → Sampler → HTTP Request
- Name it
Homepage - Fill in the Server Name or IP (e.g.,
yourdomain.com) and Path (e.g.,/for the root homepage)
- Page1 Request:
- Repeat the above steps, name it
Page1, and set the correct path (e.g.,/page1)
- Repeat the above steps, name it
- Page2 Request:
- Same process, name it
Page2, path like/page2
- Same process, name it
- Page3 Request:
- Name it
Page3, path like/page3
- Name it
Just make sure these 4 HTTP Requests are ordered from top to bottom as: Homepage → Page1 → Page2 → Page3. Each user will execute them in this exact sequence.
Step 3: (Optional) Add a Listener to Verify Execution
To double-check everything works as intended, add a View Results Tree:
- Right-click on the Thread Group → Add → Listener → View Results Tree
- Run your test, and you’ll see each user’s requests listed in order—each of the 5 users will show the 4 requests in the sequence you defined.
Extra Tips for Polish
- If you want to simulate user wait time between pages (like reading content), add a Fixed Timer between HTTP Requests: Right-click on a request → Add → Timer → Fixed Timer, then set the delay in milliseconds (e.g., 2000 for 2 seconds)
- If your pages require a logged-in session, add a HTTP Cookie Manager to the Thread Group—this automatically handles session persistence for each individual user
- If you need to pass data between pages (like a token from Homepage to Page1), use a Regular Expression Extractor or JSON Extractor to capture and reuse values
That’s all there is to it! Run your test, and each of the 5 users will follow the exact page sequence you need.
内容的提问来源于stack exchange,提问作者Akhil Kumar Patnaik

