1. Open the VSTS 2010 and click on Test New Test
2. In “Add New Test” Window in Templates list select “Web Performance Test” Enter Test name in Test name edit box (ex:-Name.WebTest) Select one of the among the displayed test project technology ( Create a new Visual C# test Project …/ Create a New Visual basic test Project…/ Create a new Visual C++ test Project … or if any Project is existed, if we want select existing project) in “ Add to Test Project:” combo box Click on OK
3. It prompts New Test Project Popup enter a name for new project and click on “Create” button. Then it creates new solution with one project and then open browser with “Record”, “Pause” and ”Stop” buttons.
4. Click on “Stop” button It creates ”Name.WebTest” file with given Web test name node
5. Right Click on Web Test name node and click on “ Add Web service Request” , then it create “http://localhost/ “ - -> “String Body” Sub nodes under Test Node name
6. Right click on “http://localhost/” node or select “http://localhost/” and press F4, it opens “Properties” pane in right hand side of the screen.
7. In Properties pane enter the WSDL (Web services define language) in URL column. WSDL is just like URL.
8. Same way open the “String Body” node Properties, Select “text/xml” in the content Type combo box and enter Web method Request in the String Body edit box
9. Right Click on “http://localhost/” node and click on “Add Header” in the drop down menu
10. Under “Headers” Node select displayed “[Enter Name]=[Enter Value]” node and open properties Pressing F4 and then Select “SoapAction” in the Name combo box and in Value edit box enter “Soap Header”. Note:- Each web service is having its own Soap Header, This value we can get from developer or in SoapUI tool in Request pane get the soap header from request XML format pane.
11. Do You want to parameterize WSDL and Soap Action Header values follow below steps
a. Right click on Web test name node (Root or Parent node) and click on “Add Data Source” item in the drop down menu
b. Select type of “Data Source Type” like CSV file or XML File or Data base and Proceed with display wizards and click on Finish button in final wizard.
c. In hard coded fields values parameterize with data source coulumns
12. Run the test and analyze the result, After successfully script executed, click on Generate code link , It prompts dialog for file name and generates the below code in “.CS” file
13. Capture the Response with “Extractvalues” event handler Add below line of code before Yield statement in the “.CS” File
Request1.ExtractValues +=new EventHandler
14. Define the Request1_ExtractValues method Like below
public void request1_Extractvalues(Object sender, ExtractionEventArgs extract)
{
var xmlResponse = extract.Response.BodyString;
XmlDocument stringxmlDocument = new XmlDocument();
stringxmlDocument.LoadXml(xmlResponse);
XmlNodeList storeVal= doc1.GetElementsByTagName("NodeName ");
}
15. Add Data base and Validation code
16. Do the build and create new web performance test following the first 4 steps for CS file execution.
17. Right click on test name node and click on “Add Call to Web Test” and Select “.CS” file in Choose Window
18. Do the build and click on “Run Test” icon
19. For Data driven test follow the below :- Test à Edit Test Settings à Local settings à In Test Settings window click on Web Test à Turn on “One run for data source row” Radio button and click on Apply à Click on “Save As” Button and save the settings with overwriting the existing file.
20. Run the test and analyze the Results
No comments:
Post a Comment