Web Performance Testing - Code behind value as dynamic parameter - c#

I've been put in charge of developing a performance test for one aspect of the system my company develops. The idea is that you upload a document, click a button, which then does a whole bunch of steps behind the scenes. The document is given a unique ID once it's uploaded, which I need to capture as a dynamic parameter so that the test can be repeated. The application is written in ASP.NET/C#, and I have no ability to view the source code or modify it in any way.
Visual Studio does not automatically pick this up as a dynamic parameter, despite the fact that it needs to be one.
Process Information
The id is generated when the document is uploaded. It's stored in the link that you click to process the document.
The id is grabbed from the code-behind at run time, through Razor code.
It is not passed through the referer to the next page, but somehow appears there anyway.
Things I've Tried
Extracting the value from the first page. This just results in having C# put in the id location instead of the actual value. Eg. 'DataItem.GetMember("ObjectId").Value' instead of '600-562949958140473'
Creating an intermediate step to get the id before moving onto the real page. I'm not sure how to do this successfully - my attempt just resulted in an additional failed step.
This is my first time working with Web Performance Testing, though I have used CodedUI. So for any explanation, please assume I'm an idiot.

Related

Open xAPI content at last bookmarked slide

I am currently opening xAPI content in our own LMS. We do not use a LRS but store statements in our own database. This will change soon as we want to build our own LRS.
When opening content, I build a string comprising the content, endpoint auth token and actor.
This will always open the content at the beginning.
If I connect to a LRS, the content is opened at the last bookmarked slide, and shows the percentage of progression.
On looking at calls made in Fiddler I can see 3 main calls being made to the LRS where the state_Id passed in is suspend_data, cumulative_time or bookmark.
Bookmark returns the Id of the last slide, and suspend data returns a load of numbers in json format.
My issue is that I can easily get the last slide Id from my database, but I cannot get the percentage or set the completed items in the package as complete (with the tick). I'm guessing the returned values from suspend_data may have something to do with setting these.
Can anyone advise on what I should be doing to open the content properly at it's bookmark?
The content itself would be in charge of opening itself to the right place based on the returned values from the queries. The content is using the State API document resources to capture those values, see https://xapi.com/blog/deep-dive-state-activity/, and then to read them back at launch so that it can set the correct state for the learner. This will also be specific to the type of content that is being run, in this case likely from a major authoring tool which has determined how it wants to store those values. Content from other authoring tools will not necessarily use those same methods. xAPI does not provide for any specifics around these details, it only defines what the LRS must support, so you will be best off implementing the LRS endpoints in the way they were intended or you'll be customizing for every kind of content you have. Also, you likely should be providing more information to the content at launch time, for instance a base activity id and a registration value.
https://xapi.com/building-a-learning-record-store/ may be a good resource to review before creating an LRS.

Load testing using VSTS. Searching from a CSV file and then clicking on the first element

I have a question regarding a performance/load testing scenario.
I understand that it's best practice not to combine more than one variable when doing a load test. However, the management is insisting on it.
Scenario: User searches for an item and then clicks on a specific item from the search results to bring up details in an i-frame.
Validation: Make sure the search is performant and the details open in the i-frame as expected- without crashing the i-frame.
I have recorded the scenario using VSTS. I am using a CSV file for the search criteria. However, how do I configure the test to click on the "first" element in the search results every time?
Thank you for very much, I apologize if I missed anything.
Correlate for the first returned item on the page. You may have to post process the returned data.
You will likely find a POST operation which follows where the results of your selection are captured. Once you have captured the data from the returned stream on the page, then use the captured data to replace the data in the post related to the item being queried.
You can also use this same captured data to validate the returned page contains the data that is expected, rather than potentially a random unrelated item, but which still returns an HTTP 200 as a valid page. Search for the appropriate unique string in the returned page data to ensure that not only you have requested the proper page, but the page you expect is being returned.

The Url where we type in address bar must not be accepted

Hello All I need all your help badly. We have made a role,ID based application in asp.net(C#) where the menu appear as per his roles. This is fine now the users are trying to directly type the link in address bars and using them. Cant restrict them in page loads and sessions as this is a production site which is already slow. So my intension is to show the url in encrypted format which expires in certain time where the user cant copy and paste it. Is there any possible way...
Cant restrict them in page loads and sessions as this is a production site which
is already slow.
Fix that crappy code and / or add more servers. Because this is the ONLY way it makes sense to do it. Anything else is the type of security that gets broken into and then you run around blaming the world for being unfair.
So my intension is to show the url in encrypted format which expires in certain
time where the user cant copy and paste it.
? So the menu has an encrypted URL that is only valid like for half a second? What if the user browses the source code of the page? He can see all the source there.
This is not security, it is hogwash. Sorry to be blunt, but this is not going to work and you are making a bad job here.
Checking this in page load will take less than a millisecond (assuming you cache roles in the session). WAY less.
Check for user role in page_load event and if the user does not have permission then redirect him to a page showing permission denied.
Please provide code if you need further help.
Yeah.... you've painted yourself into a corner here.
Short answer:
No, there's no clean way to do this and whatever type of 'special' url implementation you create will be open to abuse/spoofing and still require you to add code anyway.
Long answer:
I can't see any viable solution other than injecting some code into Page_Load.
I take it you're not using WIF/Claims-based security, just some bespoke written user login, database store based code? So your best approach (at this point) is to make a simple class in App_Code: When the user logs in, load their permissions into something like a DataTable and store that in a session variable. That way you can avoid doing database requests every time the page loads/posts back, this'll probably speed your site up a bit too.
Build a non-static method in a class that is to be used on Page_Load, where this will get the URL (or page id) being accessed, then check that against the session stored DataTable. If that check fails redirect them to an access denied page.
Building the class foundation is key, don't attempt to shortcut and copy-paste chunks of code into each page. With the 'security' class you can standardise your code and reduce testing down to a few simple checks.

Simulating Javascript 'doPostBack()' in C#

I am writing a web scaper for my company. Our client gives us access to their website for this purpose, but our client's IT team does not communicate with us, so I have to do the program with no help from the source.
Their website uses javascript on all of their buttons/dropdown menus to send postData to the server so that the screen will update to show the end user the correct info.
I am trying to get my program to simulate clicking the 'next page'. The 'next page' button has an onclick event that reads like this...
onclick="javascript:WebForm_DoPostBackWithOptions(
new WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$ucTaxQueueListView$lviewOrderQueue$DataPager2$ctl00$btnNextPage"
, "", true, "", "", false, false))"
In my C# program, i am using the HTTPWebRequest class and the HTMLAgilityPack to do my requests / scrapping respectively.
I've done all i can in my code to try and get this to work. The only thing that works is to use Fiddler to copy the postData and paste that verbatim into my WebRequest function. This is very impractical when i have to potentially go to 1000+ 'next pages'.
I have also tried extracting the ViewState from page and using that, but that always gives me an 'error' page.
Any help or guidance would be appreciated and even compensated...my boss wants this project completed this weekend!!!
The last time I had to do a project similar to this, I took a very different approach.
I used GreaseMonkey -- though you could also use a Windows HTA file with the same effect --
And I let the GreaseMonkey script run and step through the pages one by one. To handle the DoPostBack I simply invoked the click handler on the appropriate elements.
I had several data stores going.
One DataStore covered every menu item that I had "clicked" on to avoid duplicating things.
Another DataStore was the raw HTML of the page (taken by body.innerHTML)
Once I had cloned all the pages, I wrote another GreaseMonkey script to load up each saved page and mine whatever info I needed off of it. I build up a third datastore of resources (images and CSS) and then pulled those down with a big text file piped into CuRL.

Using JMeter to simulate enties in to Database

I'm trying to use Jmeter to simulate adding values, into a database from an ASP.NET website.
I have used the guide found here: https://www.youtube.com/watch?v=zYAiBwJK1v8
To setup the test, and to record the scenario. All of that seems to be working fine. The recorder, records the login to the site, and everything that comes after, including when I push the submit button to add the value to my database. When i afterwards run the recorded scenario it runs with no errors. But nothing is submittet to the database.
The scenario is this: I login to my site, (i'm using browser session id to differ between users)
Now I search for an item, the search text is parsed along with the url (this i can also confirm in the recording, in Jmeter)
Then i add this item to a tabel row in my databse using a submit button. (this also seems to be working in the recording details in Jmeter)
But nothing is added to the database when i use Jmeter to re-run the scenario. Can any one help me to find out, why or what I am missing?
I'm not sure what more information to give, but if you need more information let me know and thank you in advance
First of all I'd recommend checking that your Log In is successful using View Results Tree listener. At top left corner of the listener there will be a drop-down which defaults to Text. Select HTML (download resources) to see full response from server and verify if you're really logged in.
If not, refer to ASP.NET Login Testing with JMeter guide which highlights the peculiarities of simulating ASP.NET application log in including VIEWSTATE and EVENTVALIDATION dynamic form parameters extraction.

Categories