Proprietà ExtractText.ExtractRandomMatch

Indica se il valore estratto è scelto casualmente da tutte le corrispondenze in HtmlDocument.

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

Sintassi

'Dichiarazione
Public Property ExtractRandomMatch As Boolean
    Get
    Set
public bool ExtractRandomMatch { get; set; }
public:
property bool ExtractRandomMatch {
    bool get ();
    void set (bool value);
}
member ExtractRandomMatch : bool with get, set
function get ExtractRandomMatch () : boolean
function set ExtractRandomMatch (value : boolean)

Valore proprietà

Tipo: System.Boolean
Valore booleano che indica se il valore estratto è scelto casualmente da tutte le corrispondenze in HtmlDocument.

Note

Impostare questa proprietà su rue se si desidera che un valore venga scelto casualmente da tutte le corrispondenze nel documento XML. Impostare la proprietà quando si crea la regola di estrazione. Quindi, il motore di runtime del test delle prestazioni Web chiama Extract() dopo che è stata ricevuta la risposta HTML a WebTestRequest. Il valore della proprietà ExtractRandomMatch non viene modificato quando viene chiamato Extract().

La proprietà ExtractRandomMatch in genere viene impostata in un test delle prestazioni Web codificato in GetRequestEnumerator dopo che è stata creata la regola di estrazione ExtractText e prima che sia stato restituito WebTestRequest.

Esempi

Nell'esempio seguente viene illustrato un test delle prestazioni Web codificato il cui codice è prodotto tramite la generazione di codice. Il codice non viene modificato manualmente una volta generato. La proprietà ExtractRandomMatch viene impostata quando l'istruzione yield return Request1; viene eseguita.

namespace TestProject1
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.VisualStudio.TestTools.WebTesting;
    using Microsoft.VisualStudio.TestTools.WebTesting.Rules;


    public class ExtractRandomExampleCoded : WebTest
    {

        public ExtractRandomExampleCoded()
        {
            this.PreAuthenticate = true;
        }

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            // Initialize validation rules that apply to all requests in the WebTest
            if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.Low))
            {
                ValidateResponseUrl validationRule1 = new ValidateResponseUrl();
                this.ValidateResponse += new EventHandler<ValidationEventArgs>(validationRule1.Validate);
            }

            WebTestRequest request1 = new WebTestRequest("https://vsncts01/testwebsite");
            request1.ThinkTime = 9;
            request1.ExpectedResponseUrl = "https://vsncts01/testwebsite/";
            ExtractText extractionRule1 = new ExtractText();
            extractionRule1.StartsWith = "href=\"";
            extractionRule1.EndsWith = "\"";
            extractionRule1.IgnoreCase = false;
            extractionRule1.UseRegularExpression = false;
            extractionRule1.Required = true;
            extractionRule1.ExtractRandomMatch = true;
            extractionRule1.Index = 0;
            extractionRule1.HtmlDecode = true;
            extractionRule1.ContextParameterName = "href";
            request1.ExtractValues += new EventHandler<ExtractionEventArgs>(extractionRule1.Extract);
            yield return request1;
            request1 = null;
        }
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

ExtractText Classe

Spazio dei nomi Microsoft.VisualStudio.TestTools.WebTesting.Rules