3

I've been following this guide to create my web performance tests in VS 2013 and I found interesting thing, which I am not sure how to understand.

I have a web application. On certain request this application returns me a page, where I have a span element which has style attribute, which is equal to "color:Blue;". In my performance test I go to that page and I have "Extract Attribute Value" extraction rule to get a value of style attribute of that span tag. When I configure my rule to get attribute style1 for that tag, the rule fails (which I expect to happen), but when I create a rule with match attribute value "c@l@r-BBBB", it doesn't fail (although, I expect it to fail).

Does anybody know why?

Here is the page source:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title></head>
<body>
    <form method="post" action="Blue.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="QG+BA5tJt9bUUKK/SNJvCYaITvz71sZMdjWwNGygbhGjjs6Vy/29qy+kskbo3g4Vaz2Zfpi8hlr2F4g366EChHwtM2N676WWg0LBR3+9hc0=" />
</div>

<div class="aspNetHidden">

    <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="D66C0198" />
</div>
    <div>

        <span id="Label1" style="color:Blue;">Blue</span>

    </div>
    </form>
</body>
</html>

These is the extraction rule in .webtest, that I expect to fail:

       <ExtractionRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ExtractAttributeValue, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" VariableName="ExtractionTest" DisplayName="Extract Attribute Value" Description="Extract the value of an attribute from a specified HTML tag.">
          <RuleParameters>
            <RuleParameter Name="TagName" Value="span" />
            <RuleParameter Name="AttributeName" Value="style" />
            <RuleParameter Name="MatchAttributeName" Value="" />
            <RuleParameter Name="MatchAttributeValue" Value="c@l@r-BBBB" />
            <RuleParameter Name="HtmlDecode" Value="True" />
            <RuleParameter Name="Required" Value="True" />
            <RuleParameter Name="Index" Value="0" />
          </RuleParameters>
        </ExtractionRule>
  • There are several extraction rules in Visual Studio. Which one are you using? Without seeing the html of the successful and the unsuccessful matches (not the whole html file, just the relevant parts) your question cannot be answered. Please edit the question to add the missing details. – AdrianHHH Apr 10 '15 at 08:04
  • It would help if the question showed the properties of the extraction rule. Can you show both versions of the relevant XML from the ".webtest" file, the entire section between ``. – AdrianHHH Apr 11 '15 at 17:56

1 Answers1

2

I believe you need to specify vales for both the MatchAttributeName and the MatchAttributeValue properties. The documentation for the ExtractAttributeValue rule is not clear about what combinations of its properties are supported. However, I interpret the rule as saying: look for a TagName tag TagName where the attribute MatchAttributeName has the value MatchAttributeValue and from that tag return the value in AttributeName. Using that interpretation has always worked for me.

The documentation for AttributeName says that it "is used to identify the attribute whose value you want to extract", it does not say it is used to match any values. This documentation goes on to say that MatchAttributeName and (my emphasis) MatchAttributeValue are used in some cases.

AdrianHHH
  • 13,492
  • 16
  • 50
  • 87