Condividi tramite


Metodo ThreadedWebTest.Send

Invia una classe WebTestRequest eseguita dal motore del test delle prestazioni Web.

Spazio dei nomi:  Microsoft.VisualStudio.TestTools.WebTesting
Assembly:  Microsoft.VisualStudio.QualityTools.WebTestFramework (in Microsoft.VisualStudio.QualityTools.WebTestFramework.dll)

Sintassi

'Dichiarazione
Public Sub Send ( _
    request As WebTestRequest _
)
public void Send(
    WebTestRequest request
)
public:
void Send(
    WebTestRequest^ request
)
member Send : 
        request:WebTestRequest -> unit 
public function Send(
    request : WebTestRequest
)

Parametri

Note

Questo metodo effettua il blocco finché il modulo di test di carico Web non completa l'esecuzione della richiesta.

Esempi

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.northwind.com:80"
        End Sub
        
        Public Overrides Sub Run()
            Dim request1 As WebTestRequest = New WebTestRequest _
                ("https://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 _
                ("https://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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

ThreadedWebTest Classe

Spazio dei nomi Microsoft.VisualStudio.TestTools.WebTesting

Altre risorse

Understanding Web Tests

Working with Web Tests

Procedura: creare un test Web codificato