WebTestRequest Constructor (String^)
Initializes a new instance of the WebTestRequest class by using a URL string.
Assembly: Microsoft.VisualStudio.QualityTools.WebTestFramework (in Microsoft.VisualStudio.QualityTools.WebTestFramework.dll)
Parameters
- url
-
Type:
System::String^
The location of the resource that is being tested by the Web performance test.
This constructor sets the following property default values:
Method has a default value of "GET".
Version has a default value of "1.1".
ThinkTime has a default value of 0.
Timeout has a default value of 0.
Cache has a default value of false.
FollowRedirects has a default value of true.
If the url parameter contains query string parameters, those will be set in the QueryStringParameters property.
Legacy Code Example
The following Web performance test extracts values that represent the status of check boxes and adds the values to the context.
namespace TestProject1 { using System; using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.WebTesting; using ClassLibrary2; public class MyWebTest : WebTest { public MyWebTest() { this.PreAuthenticate = true; } public override IEnumerator<WebTestRequest> GetRequestEnumerator() { WebTestRequest request1 = new WebTestRequest("http://localhost/ts"); ExtractCheckBoxes rule1 = new ExtractCheckBoxes(); rule1.FindCheckedBoxes = true; rule1.ContextParameterName = "CheckedBoxes"; request1.ExtractValues += new EventHandler <ExtractionEventArgs>(rule1.Extract); ExtractCheckBoxes rule2 = new ExtractCheckBoxes(); rule2.FindCheckedBoxes = false; rule2.ContextParameterName = ""; request1.ExtractValues += new EventHandler <ExtractionEventArgs>(rule2.Extract); yield return request1; } } }
The following is a coded Web performance test named MyCodedWebTest that inherits from ThreadedWebTest. The second request posts to the server the form information that is contained within in three controls.
Option Strict Off Option Explicit On Imports Microsoft.VisualStudio.TestTools.WebTesting Imports Microsoft.VisualStudio.TestTools.WebTesting.Rules Imports System Imports System.Collections.Generic Namespace TestProject2 Public Class MyCodedWebTest Inherits ThreadedWebTest Public Sub New() MyBase.New Me.PreAuthenticate = true // TODO: specify your proxy below Me.Proxy = "myproxy.seattle.corp.adatum.com:80" End Sub Public Overrides Sub Run() Dim request1 As WebTestRequest = New WebTestRequest _ ("http://localhost/MyWebSite") request1.ThinkTime = 1 Dim rule1 As ExtractHiddenFields = New ExtractHiddenFields rule1.ContextParameterName = "1" AddHandler request1.ExtractValues, AddressOf rule1.Extract MyBase.Send(request1) Dim request2 As WebTestRequest = New WebTestRequest _ ("http://localhost/MyWebSite/Default.aspx") request2.Method = "POST" Dim request2Body As FormPostHttpBody = New FormPostHttpBody request2Body.FormPostParameters.Add("__VIEWSTATE", "{{$HIDDEN1" + _ ".__VIEWSTATE}}") request2Body.FormPostParameters.Add("Button1", "Button") request2Body.FormPostParameters.Add("TextBox1", "Hello text") request2.Body = request2Body Dim rule2 As ExtractHiddenFields = New ExtractHiddenFields rule2.ContextParameterName = "" AddHandler request2.ExtractValues, AddressOf rule2.Extract MyBase.Send(request2) End Sub End Class End Namespace