Aracılığıyla paylaş


ExtractText.ExtractRandomMatch Özellik

Ayıklanan değer gelen tüm eşleşmeler rastgele seçilir olup olmadığını gösterir HtmlDocument.

Ad alanı:  Microsoft.VisualStudio.TestTools.WebTesting.Rules
Derleme:  Microsoft.VisualStudio.QualityTools.WebTestFramework (Microsoft.VisualStudio.QualityTools.WebTestFramework.dll içinde)

Sözdizimi

'Bildirim
Public Property ExtractRandomMatch As Boolean
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)

Özellik Değeri

Tür: System.Boolean
Ayıklanan değer gelen tüm eşleşmeler rastgele seçilir olup olmadığını gösteren bir Boole değeri HtmlDocument.

Notlar

Bu özelliği ayarlamak rue xml belgesindeki tüm eşleri arasında rasgele seçilmiş bir değer istiyorsanız.Ayıklama kuralı oluşturduğunuzda özelliğini ayarlayın.Daha sonra WebTestRequest html yanıtı aldıktan sonra Web performans test çalışma zamanı altyapısı Extract() çağırır.Extract() çağrıldığında ExtractRandomMatch özelliğinin değeri değişmez.

ExtractRandomMatch özelliği genellikle performans test GetRequestEnumerator ExtractText ayıklama kural oluşturduktan sonra ve WebTestRequest döndürülen önce kodlanmış bir Web ayarlarsýnýz.

Örnekler

Aşağıdaki örnek kodu kod oluşturma üretilen kodlanmış bir Web performans testi gösterir.Oluşturulduğu sonra kodunu el ile değiştirilmedi.ExtractRandomMatch özelliği ne zaman ayarlı ifade yield return Request1; yürütülür.

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;
        }
    }
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

ExtractText Sınıf

Microsoft.VisualStudio.TestTools.WebTesting.Rules Ad Alanı