How to extract __OSVState from each new http ajax response

How to extract __OSVState from each new http ajax response

  

Hello,

I am working on performance testing for my application and for this I am using JMeter.

I am able to successfully record a test plan. Each http request to server has got __OSVSTATE attribute value in request.

While navigating from one page to another I am able to extract this attribute from page using Regular expression extractor and used it in the new subsequent request.

I have some pages in my applications which sends ajax requests multiple times, for each response of request a new __OSVSTATE attribute value is getting generated and sent in the <script> </script> tag json format and it seems this value gets used in the new request.

I am not able to extract __OSVSTATE value for this ajax response.

Can someone give me suggestions to achieve this in JMeter?

Thanks,

Durgesh.

Solution

Try using a regular expression such as: "__OSVSTATE":"([^"]*)"


Be aware that this value is only sent if it needs to be updated, and can be sent multiple times in the same ajax request. So I suggest you grab the last match of that regexp in the ajax response, and if there's no match, then reuse the value from the last request.

Solution

leonardo.fernandes wrote:

Try using a regular expression such as: "__OSVSTATE":"([^"]*)"


Be aware that this value is only sent if it needs to be updated, and can be sent multiple times in the same ajax request. So I suggest you grab the last match of that regexp in the ajax response, and if there's no match, then reuse the value from the last request.

Thank you Leonardo for reply, now I am able to send new __OSVSTATE values in the requests.
There are some containers in the UI that I am opening on receiving response from our integration layer (External DB) http request.
After receiving that response (i.e. records present in the DB) I am showing those containers to users by using Ajax refresh.

Each record inside container has email button using which user can send email.

In JMeter I am recording this whole process, after successful recording when I start script again in the JMeter - result tree shows response only in json format and not in HTML view like other pages.
I am able to execute email http request but for some reason mail itself is not getting sent through JMeter.
Also, there is one request- '/PerformanceProbe/rest/BeaconInternal/WebScreenClientExecutedEvent' which internally gets execute and fails.
Do you know reason behind this or if you have any other suggestions can you please share those here.

Hi Durgesh.

The output from ajax requests is a script block that gets executed by the browser to update the page. It's not HTML. So your JMeter has captured it correctly.

However, because JMeter does not record nor execute javascript code, the "buttons" will not be rendered in JMeter. This should not matter if nothing in your application changes - not even IDs of database records. If you need to record button clicks on your application and be able to replay it even with having different data, then you should be looking at UI automation - something like Selenium would do.


I don't understand your statement that the email doesn't get sent. Is the email sent on a screen action after you click the button? Any errors in Service Center? Do you have any evidence that the screen action is being executed? Most likely, there's some mismatch with your recording in JMeter, and the screen action is not being executed at all.


You can filter out any requests to PerformanceProbe. This module simply measures the performance of every request, and it doesn't affect your application in any way.

leonardo.fernandes wrote:

Hi Durgesh.

The output from ajax requests is a script block that gets executed by the browser to update the page. It's not HTML. So your JMeter has captured it correctly.

However, because JMeter does not record nor execute javascript code, the "buttons" will not be rendered in JMeter. This should not matter if nothing in your application changes - not even IDs of database records. If you need to record button clicks on your application and be able to replay it even with having different data, then you should be looking at UI automation - something like Selenium would do.


I don't understand your statement that the email doesn't get sent. Is the email sent on a screen action after you click the button? Any errors in Service Center? Do you have any evidence that the screen action is being executed? Most likely, there's some mismatch with your recording in JMeter, and the screen action is not being executed at all.


You can filter out any requests to PerformanceProbe. This module simply measures the performance of every request, and it doesn't affect your application in any way.

Thanks Leonardo for reply.
Yes, the email is getting triggered on click of send button via one screen action. (not working in JMeter)
As buttons will not rendered in JMeter will its associated action get execute ? I think this is not getting executed.

There are no any errors in service center apart from the one that I mentioned in above post. Can we catch internal rest requests in JMeter ? those rest calls I am using to save some data into external DB.

If selenium is the solution for this issue, will it execute associated button action ?

I also think the screen action is not being executed. Can you check whether the data you're saving on the screen action is changing on the database?

Another thing you can do is have a site property called "ButtonClicks" that starts at 0, and at the start of the screen action you increment it +1. Then you would be able to tell how many times the screen action was called. If the site property is not changed when you run the JMeter script, you know for sure that the screen action wasn't executed.


The theory behind recording HTTP traffic in OutSystems is as follows. Every button click sends to the server the viewstate, the values of input fields, and the name of the button that was clicked. The viewstate contains a description of which records were displayed, and also which buttons and inputs were displayed on the page (this is a large oversimplification, but in essence that's what the viewstate is all about). With this information, the server is able to reconstruct the page and execute the corresponding click event handler.

If you are careful enough to carry the viewstate from one request to the next (as I've instructed you on previous posts), and if you correctly recorded in JMeter the values of the inputs and the name of the button that was clicked, then the server should be able to execute the screen action - even without having a browser rendering and executing any javascript.


A few things could go wrong on that process. Maybe the name of inputs or buttons have changed from since you've recorded the JMeter script. In that case, you're sending names that won't be useful for the server to recreate the page. They could easily change if you change the order of things in the user interface, or if you change the name of widgets. They could also change if the data being rendered has changed since you've recorded the script.

The viewstate will also be different for each execution, because it is encrypted. That's why you must dynamically propagate the viewstate from one request into the next. If you fail to do that for just a single request, all subsequent requests will fail.


Selenium is a different beast. You won't be able to use for load testing (as far as I know). But if you just want to automate some functional test, then please have a look into Selenium.