Skip to main content

Visual Studio Webtest : Adding Timeout Plugin for Requests

Introduction:

There are a wide range of applications which perform according to various circumstances.Some are fast and some are slow.When we hit a particular request ,there is a timeout value set to determine whether the request has been processed within the desired time limit set.In order to set the request timeout property there is an option in Visual Studio Webtest for each request properties to set the Timeout value.


But if there are a large no. of requests in your Webtest ,changing the value for each and every request is a tedious task.But not to worry,this is where the Webtest plugins comes in handy! The request timeout property for the all the requests inside a Webtest can manged with a single property.Here are steps which has to be followed :

1.Create a Web Performance and Load Test Project in Visual Studio as shown below :



2.Right click the project and add a new item :


3.Choose Class item from the menu and give desired name for the plugin file :


4.Implement the code as shown below for adding Request timeout using this plugin :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.WebTesting;
using System.ComponentModel;

namespace SampleWebtest
{
    [Description("This plugin can be used to set the Timeout property for each request")]
   public class Timeout : WebTestPlugin
    {
        public int timeout_seconds;
        public override void PreRequest(object sender, PreRequestEventArgs e)
        {
            e.Request.Timeout = timeout_seconds;//Setting time out value for each request
            }
        [DefaultValue(60)]
        [Description("All requests will have their Timeout Requests property set to this value")]
        public int RequestTimeout
        {
            get
                {
                return timeout_seconds;
                      }
            set
                {
                timeout_seconds = value;
                    }

        }
    }

}


 Note : Don't forget to include the following headers :
            using Microsoft.VisualStudio.TestTools.WebTesting;
       using System.ComponentModel;

5.Build the solution.
6.Right Click the Webtest and select "Add Request Plugin".


7.Select Timeout plugin-in and set your desired input value for the requests Timeout.



Voila! You have successfully set the timeout value globally for all the requests in the Webtest.

Comments

Post a Comment

Popular posts from this blog

Loadrunner ~ Performance Testing with Citrix Protocol : Recording Tips n Tricks!

1 . INTRODUCTION 1.1 Citrix Protocol in load runner Recording Tips When recording a script, be sure to follow these guidelines in order to create an effective script. Single vs. Multi-Protocol Scripts When creating a new script, you may create a single protocol or multi-protocol script. If you plan to record a simple Citrix ICA session, use a single protocol script. When recording an NFUSE Web Access session, however, you must create a multi-protocol script for Citrix ICA and Web (HTML/HTTP), to enable the recording of both protocols. Record into Appropriate Sections Record the connection process into the vuser_init section, and the closing process into the vuser_end section. This will prevent you from performing iterations on the connecting and disconnecting. Run a Clean Session When recording a session, make sure to perform the complete business process, starting with the connection and ending with the cleanup. End your session at a point from where you could sta

Peformance Testing with Citrix Protocol : Citrix ICA Vuser Functions (CTRX)

Mouse Functions ctrx_mouse_click Emulates a mouse click on a Citrix client ctrx_mouse_double_click Emulates a double mouse click on a Citrix client ctrx_mouse_down Emulates a mouse down click on a Citrix client ctrx_mouse_move Emulates a mouse move on a Citrix client sent to a Citrix server. ctrx_mouse_up Emulates a mouse up click on a Citrix client ctrx_mouse_click Emulates a mouse click on a Citrix client sent to a Citrix server. int ctrx_mouse_click( long x_pos, long y_pos, long mouse_button, long key_modifier, char *window_name, [CONTINUE_ON_ERROR,] CTRX_LAST ); int ctrx_obj_mouse_click( const char *obj_desc, long x_pos, long y_pos, long mouse_button, long key_modifier, char *window_name, [CONTINUE_ON_ERROR,] CTRX_LAST ); obj_desc A description of the object recorded if the agent is installed on the server. x_pos The horizontal distance of t

ATM API Loadtesting with Sybase ASE using LOADRUNNER 12.60

Introduction            SAP ASE   (Adaptive Server Enterprise), originally known as   Sybase   SQL Server, and also commonly known s   Sybase   DB or   Sybase ASE , is a relational model database server product for businesses developed by   Sybase   Corporation which became part of   SAP  AG. Metrics Considered for load testing of ATM APIs ·          Transaction per Minute (TPM) e.g : 600 TPM ·          Transaction per second (TPS) e.g: 10 TPS Setting up Database connection ODBC Data Source Administrator For 32 bit: C:\Windows\system32\ odbcad32 For 34 bit: C:\Windows\SysWOW64\ odbcad32 Add a new Data Source for Sybase ASE                                  LR Scripting: Web-HTTP/HTML Protocol Action () {          lr_start_transaction ( " P_API_XXXXXX_XXXXXX _ExecuteQuery" );        //Establishing ODBC driver Connection // Connection String for Sybase ASE : //ConnectionString=Dsn={ODBC Reference Name};Uid={use