FormPostHttpBody Sınıf
Bir HTML form post gövde ile form parametreleri topluluğu temsil eder.
Devralma Hiyerarşisi
Object
Microsoft.VisualStudio.TestTools.WebTesting.FormPostHttpBody
Ad alanı: Microsoft.VisualStudio.TestTools.WebTesting
Derleme: Microsoft.VisualStudio.QualityTools.WebTestFramework (Microsoft.VisualStudio.QualityTools.WebTestFramework.dll içinde)
Sözdizimi
'Bildirim
<SerializableAttribute> _
Public Class FormPostHttpBody _
Implements IHttpBody, ICloneable
[SerializableAttribute]
public class FormPostHttpBody : IHttpBody,
ICloneable
[SerializableAttribute]
public ref class FormPostHttpBody : IHttpBody,
ICloneable
[<SerializableAttribute>]
type FormPostHttpBody =
class
interface IHttpBody
interface ICloneable
end
public class FormPostHttpBody implements IHttpBody, ICloneable
FormPostHttpBody türü aşağıdaki üyeleri ortaya koyar.
Oluşturucular
Ad | Açıklama | |
---|---|---|
FormPostHttpBody | FormPostHttpBody sınıfının yeni bir örneğini başlatır. |
Üst
Özellikler
Ad | Açıklama | |
---|---|---|
ContentType | Gönderilen veriler içerik türünü gösteren bir değeri alır. | |
FormPostParameters | Bu FormPostParameters listesini alır FormPostHttpBody. |
Üst
Yöntemler
Ad | Açıklama | |
---|---|---|
Clone | Derin bir kopyasını verir FormPostHttpBody. | |
Equals | Determines whether the specified object is equal to the current object. (Object kaynağından devralındı.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Object kaynağından devralındı.) | |
GetHashCode | Serves as the default hash function. (Object kaynağından devralındı.) | |
GetType | Gets the Type of the current instance. (Object kaynağından devralındı.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Object kaynağından devralındı.) | |
ToString | Returns a string that represents the current object. (Object kaynağından devralındı.) | |
WriteHttpBody | HTTP Gövde akışı yazar. |
Üst
Notlar
Bu tür bir HTTP Gövde içinde sunucuya veri göndermek için POST yöntemi tarafından kullanılan bilgi için bir kapsayıcıdır.Bu sınıf seri hale getirilebilir.
Örnekler
Aşağıdaki kod örnekleri Göster nasıl bir FormPostHttpBody gövdesi ile form gönderme parametreleri ekler WebTestRequest.
namespace TestProject1
{
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.WebTesting;
using Microsoft.VisualStudio.TestTools.WebTesting.Rules;
public class MyCodedWebTest : WebTest
{
public override IEnumerator<WebTestRequest> GetRequestEnumerator()
{
WebTestRequest request1 = new WebTestRequest("https://localhost/MyWebSite");
request1.ThinkTime = 14;
ExtractHiddenFields rule1 = new ExtractHiddenFields();
rule1.ContextParameterName = "1";
request1.ExtractValues += new EventHandler<ExtractionEventArgs>(rule1.Extract);
yield return request1;
WebTestRequest request2 = new WebTestRequest("https://localhost/MyWebSite/Default.aspx");
request2.Method = "POST";
FormPostHttpBody request2Body = new FormPostHttpBody();
request2Body.FormPostParameters.Add("__VIEWSTATE", "{{$HIDDEN1.__VIEWSTATE}}");
request2Body.FormPostParameters.Add("Button1", "Button");
request2Body.FormPostParameters.Add("TextBox1", "text entered");
request2.Body = request2Body;
yield return request2;
}
}
}
Option Strict Off
Option Explicit On
Imports Microsoft.VisualStudio.TestTools.WebTesting
Imports Microsoft.VisualStudio.TestTools.WebTesting.Rules
Imports System
Imports System.Collections.Generic
Namespace MyVBTestProject
Public Class MyCodedWebTest
Inherits ThreadedWebTest
Public Sub New()
MyBase.New
Me.PreAuthenticate = true
Me.Proxy = "myproxy.com:80"
End Sub
Public Overrides Sub Run()
Dim request1 As WebTestRequest = New WebTestRequest _
("https://localhost/MyWebSite")
request1.ThinkTime = 10
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", "Entered text")
request2.Body = request2Body
MyBase.Send(request2)
End Sub
End Class
End Namespace
İş Parçacığı Güvenliği
Bu türün tüm genel statik (Visual Basic'te Shared) üyeleri iş parçacığı açısından güvenlidir. Hiçbir örnek üyesinin iş parçacığı açısından güvenliği garanti edilemez.
Ayrıca bkz.
Başvuru
Microsoft.VisualStudio.TestTools.WebTesting Ad Alanı