Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Gets the list of FormPostParameters included in this FormPostHttpBody.
Namespace: Microsoft.VisualStudio.TestTools.WebTesting
Assembly: Microsoft.VisualStudio.QualityTools.WebTestFramework (in Microsoft.VisualStudio.QualityTools.WebTestFramework.dll)
Syntax
'Declaration
Public ReadOnly Property FormPostParameters As FormPostParameterCollection
public FormPostParameterCollection FormPostParameters { get; }
public:
property FormPostParameterCollection^ FormPostParameters {
FormPostParameterCollection^ get ();
}
member FormPostParameters : FormPostParameterCollection
function get FormPostParameters () : FormPostParameterCollection
Property Value
Type: Microsoft.VisualStudio.TestTools.WebTesting.FormPostParameterCollection
A FormPostParameterCollection collection that contains each FormPostParameter associated with this FormPostHttpBody.
Examples
The following code sample shows how a FormPostHttpBody adds form post parameters to the body of the WebTestRequest. The first form post parameter is adding viewstate information from a hidden field. The second and third parameters add the name and value attributes of the controls to the form post parameter collection.
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;
}
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.