问题
I'm a .net developer having no prior experience in JMeter/Stress testing. I'm trying to load test the ASP.net website that I had developed using JMeter. The reason for using JMeter is that its an open source tool having lots of fame and credibility.
I referred to this link in order to take care of viewstate which is a typical feature of ASP.net. However my requirements are not that simple as stated there. I'm trying to load test my site by sending userid and password to log-in page and then test through other pages which are allowed to be browsed only if log-in is successful.
The steps that I'm taking to achieve this are listed below.
- Create Http Proxy Server by selecting WorkBench > Add > Non-Test Elements.
- Changing the network settings in Firefox to the port defined in Http Proxy Server.
- Creating a
Thread Group
by selecting Test Plan > Add > Threads(Users) > Thread Group. - Creating
HTTP Request Defaults
by selecting Thread Group > Add > Config Element > HTTP Request Defaults. - (a) Entering IP for my remote server in
Server Name or IP:
(b) Entering the path to my log-in page as/MyWebApplication/login.aspx
- Create
User Defined Variables
by selecting Thread Group > Add > Config Element > User Defined Variables. My login.aspx page is very simple, it takes userid and password from two text-boxes and match them in database and if successful, redirects them to LoginSuccess.aspx page.
My login.aspx has three server controls only, twoasp:TextBox
for receiving loginid and password and oneasp:Button
for checking them in db.
The id of them aretxtLogin
,txtPassword
,btnLogin
respectively.In User Defined variables (created in step 6), I've added admin and 123admin, which are real logins in db getting checked in login.aspx page and on success is redirecting to LoginSuccess.aspx page.
User defined variables:
Name: Value Description login admin password 123admin
I'm adding two Regular Expression Extractor by selecting Thread Group > Add > Post Processors > Regular Expression Extractor.
I've renamed the 1st Regular Expression Extractor as
View State Extractor
and adding following data to them:Reference Name: viewstate Regular Expression: name="__VIEWSTATE" id="__VIEWSTATE" value="(.+?)" Template:$1$ Match No.(0 for Random): 1 Default Value: ERROR
Similarly I've renamed the 2nd Regular Expression Extractor as
Event Validation Extractor
and adding following data to them:Reference Name: eventValidation Regular Expression: name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="(.+?)" Template:$1$ Match No.(0 for Random): 1 Default Value: ERROR
In step 5 I added following data
Send Parameters With the Request: Name: - Value txtLogin - $(login) txtPassword - $(password) __VIEWSTATE - $(viewState) __EVENTVALIDATION - $(eventValidation)
Now I added HTTP Cookie Manager by selecting Thread Group > Add > Config Element > HTTP Cookie Manager.
Now I added Recording Controller by selecting Thread Group > Add > Logic Controller > Recording Controller.
I started HTTP Proxy Server and then using firefox entered the complete URL to my login.aspx page, entered admin and 123admin in the two text boxes and pressed the Login button and got redirected successfully on LoginSuccess.aspx. I stopped the HTTP Proxy Server and closed my firefox browser.
Now I've saved the test plan (containing the recorded steps, just 2 steps here, 1 for login.aspx and another for LoginSuccess.aspx) and running the test and viewing the test result in View Result Tree which is returning 500 error from the server.
I'm unable to determine what ingredient I'm missing here because of which I can't successfully use JMeter. I've only changed those values which are mentioned here and for everything that I didn't write here the values are default type like No of thread:
.
回答1:
- Please add better schema of your script at least.
- Well, in step 11 above you have
txtLogin = $(login)
,txtPassword = $(password)
, ...
Referring variable value as$(VAR_NAME)
is incorrect,${VAR_NAME}
should be used.
Can you ensure if that only misspelling in your question - or you have the same in the script? - Use e.g. Debug Sampler / Debug PostProcessor (inserted after both RegEx Extractors applied) to check that values for both
viewstate
andeventValidation
were extracted from your request and your regex queries work correctly. - Look into the Request panel of your 2nd HTTP Request sampler in View Result Tree results to ensure that all the defined params (
txtLogin
,txtPassword
,__VIEWSTATE
,__EVENTVALIDATION
) with correct values are sent along with request.
回答2:
In step 5, change as follows
Name: - Value
txtLogin - ${login}
txtPassword - ${password}
__VIEWSTATE - ${viewState}
__EVENTVALIDATION - ${eventValidation}
Also verify, regular expression extractor is working as required. I mean check if it is fetching correct values.
回答3:
I used CSS/JQuery Extractor and it worked for me. With regex extractor for view state {viewState} variable was getting passed and got view state corrupt error message.
parameters to be set in CSS/JQuery extractor are :-
Reference Name: viewState
CSS/JQuery Expression: input[id=__VIEWSTATE]
Attribute: value
The steps i followed are :-
- First do recording of login process.
- Drag the required pages in thread group.
- In get request of login page add two CSS/JQuery extractor for view state and event validation each.
In post request of login page add body parameters as follows and run the batch.
Name: - Value
txtLogin - ${login}
txtPassword - ${password}
__VIEWSTATE - ${viewState}
__EVENTVALIDATION - ${eventValidation}
回答4:
Http 500 is. A server error code so it is not your script that's is failing what has to be done is a tag in the .aspx to disabled the security I faced this some months ago
来源:https://stackoverflow.com/questions/15248712/how-to-use-jmeter-for-load-testing-asp-net-web-applications-implementing-viewsta