Background
I'm working on a project written in ASP.net and C#. The backend data is handled in MSSQL.
Upon visiting a homepage the user is presented a tree-view of the different pages they can visit. This tree-view is of the .sitemap type filled will siteMapNode's. A user can expand the tree-view and drill down two or three levels to visit the actual page they intend to view.
Every end-node on this tree-view terminates with a link to a reporting page (the .aspx. The reporting page (.aspx) consists of any number of asp:DropDownList's containing any number of asp:ListItem's. Once all of the drop downs have been selected and the selection is valid an asp:Button is presented and upon a click an asp:Panel containing a rsweb:ReportViewer which actually displays the .rdlc report to be displayed to the user. Something that might be worth mentioning because it might have a negative consequence on my tests is that all or most of these DropDownLists are set AutoPostBack="True".
What I'm Looking For
I'm hoping that I can add a C# Web Performance and Load Test Project to my existing solution that will run tests on all the pages I have in my project.
I want to write automated tests that can open/visit my .sitemap's and then proceed to open/visit every link that is in that sitemap.
On each and every page linked from that sitemap I'd like the tests to loop through every asp:DropDownList and every asp:ListItem in that drop down list then 'click' the asp:Button and give me a 'Pass' when the .rdlc loads into the rsweb:ReportViewer.
In parallel with the button click and report load I'd also like to run a timer to see how long the data fetch takes and add the load time for that data into the rdlc as well.
So...
Is this possible to accomplish using the Web Performance tests in visual studio?
What I've Tried So Far
I've tried adding a web tests project to my existing solution. I then proceeded to create a recorded test and then generate the code from that recorded web test. It looked like it created many lines of excess code that I don't think I necessarily need regarding the desired outcome of my tests. For example below is one of the tests run in which I comment out about 24 lines of code that looks irrelevant.
WebTestRequest request23 = new WebTestRequest("http://localhost/project/directory/reportPage.aspx");
request23.Method = "POST";
request23.Headers.Add(new WebTestRequestHeader("referer", "http://localhost/project/directory/reportPage.aspx"));
request23.Headers.Add(new WebTestRequestHeader("x-requested-with", "XMLHttpRequest"));
request23.Headers.Add(new WebTestRequestHeader("x-microsoftajax", "Delta=true"));
FormPostHttpBody request23Body = new FormPostHttpBody();
request23Body.FormPostParameters.Add("ctl00$ScriptManager1", "ctl00$Updatepanel1|ctl00$Main$ddlFilterBy");
// here are the values of the drop downs I'd like to test but I'd like to
// loop through all the items in the drop down for each one and test them all
request23Body.FormPostParameters.Add("ctl00$Main$ddlReportType", "Detail");
request23Body.FormPostParameters.Add("ctl00$Main$ddlProgram", "FS");
request23Body.FormPostParameters.Add("ctl00$Main$ddlDueMonth", "10/31/2015");
request23Body.FormPostParameters.Add("ctl00$Main$ddlFilterBy", "Unit");
request23Body.FormPostParameters.Add("ctl00$Main$ddlOffice", "Another drop down selection");
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl03$ctl00", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl03$ctl00"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl03$ctl01", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl03$ctl01"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl10", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl10"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl11", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl11"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$AsyncWait$HiddenCancelField", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$AsyncWait$HiddenCancelField"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ToggleParam$store", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ToggleParam$store"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ToggleParam$collapse", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ToggleParam$collapse"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl05$ctl00$CurrentPage", "1");
//request23Body.FormPostParameters.Add("null", "100");
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl05$ctl03$ctl00", "");
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl08$ClientClickedId", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl08$ClientClickedId"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl07$store", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl07$store"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl07$collapse", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl07$collapse"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl09$VisibilityState$ctl00", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl09$VisibilityState$ctl00"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl09$ScrollPosition", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl09$ScrollPosition"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl09$ReportControl$ctl02", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl09$ReportControl$ctl02"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl09$ReportControl$ctl03", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl09$ReportControl$ctl03"].ToString());
//request23Body.FormPostParameters.Add("ctl00$Main$ReportViewer1$ctl09$ReportControl$ctl04", this.Context["$HIDDEN2.ctl00$Main$ReportViewer1$ctl09$ReportControl$ctl04"].ToString());
//request23Body.FormPostParameters.Add("__EVENTTARGET", "ctl00$Main$ddlFilterBy");
//request23Body.FormPostParameters.Add("__EVENTARGUMENT", this.Context["$HIDDEN2.__EVENTARGUMENT"].ToString());
//request23Body.FormPostParameters.Add("__LASTFOCUS", this.Context["$HIDDEN2.__LASTFOCUS"].ToString());
//request23Body.FormPostParameters.Add("__VIEWSTATE", this.Context["$HIDDEN2.__VIEWSTATE"].ToString());
//request23Body.FormPostParameters.Add("__VIEWSTATEGENERATOR", this.Context["$HIDDEN2.__VIEWSTATEGENERATOR"].ToString());
//request23Body.FormPostParameters.Add("__EVENTVALIDATION", this.Context["$HIDDEN2.__EVENTVALIDATION"].ToString());
//request23Body.FormPostParameters.Add("__ASYNCPOST", "true");
request23.Body = request23Body;
ExtractHiddenFields extractionRule12 = new ExtractHiddenFields();
extractionRule12.Required = true;
extractionRule12.HtmlDecode = true;
extractionRule12.ContextParameterName = "2";
request23.ExtractValues += new EventHandler<ExtractionEventArgs>(extractionRule12.Extract);
yield return request23;
request23 = null;
I've also looked into Selenium but I really like the idea of the Coded Web Tests because I can check it into my TFS source control.
My biggest dilemma is that I cannot find any kind of literature/tutorials/walkthroughs on anything close to what I'm trying to accomplish. Second and more importantly is having the tests dynamically know how many drop down lists exist on the page upon test start. And then dynamically going through every ListItem in that DropDown and testing every option for them and then knowing whether the page loaded (pass) or spits out an error (fail).
I guess if any of this is possible then may test driven development involving asp.net and coded UI tests would be possible and if that were the case I'd like to proceed that way in coding my reports from now on.
If anyone has ever touched on this and worked in this kind of environment I would be all ears because manually testing every report/page we have would take weeks and is very tedious.
Aucun commentaire:
Enregistrer un commentaire