Create a More Specific Rule

A more specific rule that creates a parsing function only for the session ID is needed. There are several ways of achieving this.

The Recorder uses the boundary strings in the Search attribute of parsing rules to extract substrings from each HTTP response. These substrings are called "rule hits" or simple "hits." The Recorder remembers each hit. When scripting a string, the Recorder checks to see if any of the identified rule hits are included in the scripted string. If they are, the Recorder generates a parsing function for the rule hit and substitutes the resulting variable into the scripted strings.

Limit the number of rule hits

A more specific rule can be created based on the unique characteristics of ShopIt V 6.0 Session IDs.

Session ID properties to consider:
  • They consist of digits only.
  • Their length is always 9 digits.

Taking this into account, the rule can be extended.

Limit the number of rule hits by conditions

<?xml version="1.0" encoding="UTF-8" ?>
<RecordingRuleSet>

  <HttpParsingRule>
    <Name>ShopIt V6.0 Session Id</Name>
      <Search>
        <SearchIn>Body</SearchIn>
        <LB>
          <Str>name=&quot;</Str>
        </LB>
        <RB>
          <Str>&quot;</Str>
        </RB>
        <CondRegExpr>[0-9]+</CondRegExpr>
        <CondResultLen>9-9</CondResultLen>
      </Search>
    <ScriptGen>
      <VarName>ShopItSessionId</VarName>
    </ScriptGen>
  </HttpParsingRule>
</RecordingRuleSet>

The attribute Search\CondRegExpr specifies a regular expression that is applied to each rule hit. Rule hits that do not match this regular expression are dropped. The regular expression in the example above specifies that only rule hits consisting of digits are relevant.

The attribute Search\CondResultLen specifies a range of acceptable length for rule hits. Example above specifies that only hits with exactly nine characters are relevant. A subsequent recording session using this modified rule is successful: The recorded script contains a parsing function for the session ID only.

Script recorded using a modified rule

var
  gsShopItSessionId : string; // 348364011

dclform
  SHOPITV60_KINDOFPAYMENT_ASP003:
  "choice" := "CreditCard",
  "price" := "15.9",
  "sid" := gsShopItSessionId; // value: "348364011"

MYFORM004:
  "address" := "a", // changed
  "city" := "b", // changed
  "state" := "c", // changed
  "zip" := "" <SUPPRESS> , // value: ""
  "ZipCode" := "d", // added
  "cardtype" := "Visa", // added
  "cardnumber" := "111-111-111", // changed
  "expiration" := "07.04", // changed
  "sid" := "" <USE_HTML_VAL> ;//value:"348364011"

Specify allowed usage of rule hits

Rather than limiting the number of rule hits, one can be more specific in specifying where in scripts rule hits are to be used. Consider the following for this example: The session ID occurs only in form field values where the form field name is "sid". By extending the ScriptGen section of the parsing rule (as shown in the example below), rule hits are used only under these specific criteria.

Be more specific in script generation

<?xml version="1.0" encoding="UTF-8"?>
<RecordingRuleSet>

  <HttpParsingRule>
    <Name>ShopIt V6.0 Session Id</Name>
    <Search>
      <SearchIn>Body</SearchIn>
      <LB>
        <Str>name=&quot;</Str>
      </LB>
      <RB>
        <Str>&quot;</Str>
      </RB>
    </Search>
    <ScriptGen>
      <VarName>ShopItSessionId</VarName>
      <ReplaceIn>FormFieldValue</ReplaceIn>
      <Conditions>
        <CompareData>
          <Data>sid</Data>
          <ApplyTo>FormFieldName</ApplyTo>
        </CompareData>
      </Conditions>
    </ScriptGen>
  </HttpParsingRule>
  
</RecordingRuleSet>

The attribute ScriptGen\ReplaceIn specifies that rule hits may only be used when the Recorder scripts a form field value. The condition additionally specifies that a replacement is allowed only if the associated form field name is sid. Recording with this modified rule generates a script that is identical to the script generated using the original rule.