ThreadedWebTest.Send 方法
发送一个要由 Web 性能测试引擎运行的 WebTestRequest。
命名空间: Microsoft.VisualStudio.TestTools.WebTesting
程序集: Microsoft.VisualStudio.QualityTools.WebTestFramework(在 Microsoft.VisualStudio.QualityTools.WebTestFramework.dll 中)
语法
声明
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
)
参数
request
类型:Microsoft.VisualStudio.TestTools.WebTesting.WebTestRequest要运行的一个 WebTestRequest。
备注
在 Web 负载测试引擎运行完请求之前,该方法阻塞。
示例
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
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。
请参阅
参考
Microsoft.VisualStudio.TestTools.WebTesting 命名空间