...

Source file src/github.com/clbanning/mxj/v2/examples/gonuts12seq.go

Documentation: github.com/clbanning/mxj/v2/examples

     1  /* gonuts10seqB.go - https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/tf4aDQ1Hn_c
     2  
     3  Objective:  to quote from email
     4  
     5  ================================ BEGIN QUOTE
     6  I'm actually dealing with Microsoft webtest files. An example can be find at,
     7  
     8  https://gist.github.com/suntong/e4dcdc6c85dcf769eec4
     9  
    10  It is the same as our case -- we have comments before each "<Request", and the requests and comments are grouped into transactions. For *each* request, I need to change one of its sub-node with the content from its leading comments, and from the content of the grouping transaction as well.
    11  
    12  Using the above example to explain in details, the first Request is,
    13  
    14      <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ...
    15  
    16  The comments immediately before it, its leading comments, is,
    17  
    18      <Comment CommentText="Visit Homepage ...
    19  
    20  The fist Transaction is,
    21  
    22      <TransactionTimer Name="Show Hide Widget List">
    23  
    24  Under it, the requests and comments are grouped into this transaction.
    25  
    26  
    27  Now the challenge is, for *each* request with a comment immediately before it, change it attribute "ReportingName="""''s value with the content from its leading comments, and from the content of the grouping transaction as well. Let's say, first 10 chars or first three words or each. So for the first Request under "<TransactionTimer Name="Show Hide Widget List">", which is "<Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ...", it's attribute "ReportingName=""" should be changed to,
    28  
    29     ReportingName="Show Hide Widget, Show Widget List"
    30  
    31  Everything else should remain exactly the same.
    32  ========================== END OF QUOTE
    33  
    34  NOTE: use NewMapXmlSeq() and mv.XmlSeqIndent() to preserve structure.
    35  
    36  ALSO: we will ignore Comment/Request entiries in WebTest.Items list.
    37  
    38  See data value at EOF - from: https://gist.github.com/suntong/e4dcdc6c85dcf769eec4
    39  */
    40  
    41  package main
    42  
    43  import (
    44  	"bytes"
    45  	"fmt"
    46  	"github.com/clbanning/mxj"
    47  	"io"
    48  )
    49  
    50  func main() {
    51  	// fmt.Println(string(data))
    52  	rdr := bytes.NewReader(data)
    53  	// We read processing docs sequentially.
    54  	// Un-rooted ProcInst or Comments are processed AND just re-encoded. (XmlSeqIndent() knows how, now.)
    55  	for m, err := mxj.NewMapXmlSeqReader(rdr); m != nil || err != io.EOF; m, err = mxj.NewMapXmlSeqReader(rdr) {
    56  		if err != nil {
    57  			if err != mxj.NoRoot {
    58  				fmt.Println("NewMapXmlSeq err:", err)
    59  				fmt.Println("m:", m)
    60  			} else if m != nil {
    61  				x, _ := m.XmlSeqIndent("", "  ")
    62  				fmt.Println(string(x))
    63  			}
    64  			continue
    65  		}
    66  		// fmt.Println(m.StringIndent())
    67  
    68  		// get the array of TransactionTimer  entries for the 'path'
    69  		vals, err := m.ValuesForPath("WebTest.Items.TransactionTimer")
    70  		if err != nil {
    71  			fmt.Printf("ValuesForPath err: %s", err.Error())
    72  			continue
    73  		} else if len(vals) == 0 {
    74  			fmt.Printf("no vals for WebTest.Items.TransactionTimer")
    75  			continue
    76  		}
    77  		// process each TransactionTimer element ...
    78  		for _, t := range vals {
    79  			tmap := t.(map[string]interface{})
    80  			// get Name from attrs
    81  			tname, _ := mxj.Map(tmap).ValueForPathString("#attr.Name.#text")
    82  
    83  			// now process TransactionTimer.Items value ... is a map[string]interface{} value
    84  			// with Comment and Request keys with array values
    85  			vm, ok := tmap["Items"].(map[string]interface{})
    86  			if !ok {
    87  				fmt.Println("assertion failed")
    88  				return
    89  			}
    90  			// get the Comment list
    91  			c, ok := vm["Comment"]
    92  			if !ok { // --> no Items.Comment elements
    93  				continue
    94  			}
    95  			// Don't assume that Comment is an array.
    96  			// There may be just one value, in which case it will decode as map[string]interface{}.
    97  			switch c.(type) {
    98  			case map[string]interface{}:
    99  				c = []interface{}{c}
   100  			}
   101  			cmt := c.([]interface{})
   102  			// get the Request list
   103  			r, ok := vm["Request"]
   104  			if !ok { // --> no Items.Request elements
   105  				continue
   106  			}
   107  			// Don't assume the Request is an array.
   108  			// There may be just one value, in which case it will decode as map[string]interface{}.
   109  			switch r.(type) {
   110  			case map[string]interface{}:
   111  				r = []interface{}{r}
   112  			}
   113  			req := r.([]interface{})
   114  
   115  			// fmt.Println("Comment:", cmt)
   116  			// fmt.Println("Request:", req)
   117  
   118  			// Comment elements with #seq==n are followed by Request element with #seq==n+1.
   119  			// For each Comment.#seq==n extract the CommentText attribute value and use it to
   120  			// set the ReportingName attribute value in Request.#seq==n+1.
   121  			for _, v := range cmt {
   122  				vmap := v.(map[string]interface{})
   123  				seq := vmap["#seq"].(int) // type is int
   124  				// extract CommentText attr from array of "#attr"
   125  				acmt, _ := mxj.Map(vmap).ValueForPathString("#attr.CommentText.#text")
   126  				if acmt == "" {
   127  					fmt.Println("no CommentText value in Comment attributes")
   128  				}
   129  				// fmt.Println(seq, acmt)
   130  				// find the request with the #seq==seq+1 value
   131  				var r map[string]interface{}
   132  				for _, vv := range req {
   133  					rt := vv.(map[string]interface{})
   134  					if rt["#seq"].(int) == seq+1 {
   135  						r = rt
   136  						break
   137  					}
   138  				}
   139  				if r == nil { // no Request with #seq==seq+1
   140  					continue
   141  				}
   142  				if err := mxj.Map(r).SetValueForPath(tname+", "+acmt, "#attr.ReportingName.#text"); err != nil {
   143  					fmt.Println("SetValueForPath err:", err)
   144  					break
   145  				}
   146  			}
   147  		}
   148  
   149  		// re-encode the map with the TransactionTimer.#attr.Name & Items.Comment[#seq==n].#attr.CommentText
   150  		// values copied to the Items.Request[#seq==n+1].#attr.ReportingName elements.
   151  		b, err := m.XmlSeqIndent("", "  ")
   152  		if err != nil {
   153  			fmt.Println("XmlIndent err:", err)
   154  			return
   155  		}
   156  		fmt.Println(string(b))
   157  	}
   158  }
   159  
   160  var data = []byte(`
   161  <?xml version="1.0" encoding="utf-8"?>
   162  <WebTest Name="FirstAnonymousVisit" Id="ac766d08-f940-4b0a-b8f8-80675978894e" Owner="" Priority="0" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="0" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="" StopOnError="False" RecordedResultFile="">
   163    <Items>
   164      <Comment CommentText="Visit Homepage and ensure new page setup is created" />
   165      <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0.5" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   166        <ValidationRules>
   167          <ValidationRule Classname="Dropthings.Test.Rules.CookieValidationRule, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Check Cookie From Response" Description="" Level="High" ExectuionOrder="BeforeDependents">
   168            <RuleParameters>
   169              <RuleParameter Name="StopOnError" Value="False" />
   170              <RuleParameter Name="CookieValueToMatch" Value="" />
   171              <RuleParameter Name="MatchValue" Value="False" />
   172              <RuleParameter Name="Exists" Value="True" />
   173              <RuleParameter Name="CookieName" Value="{{Config.TestParameters.AnonCookieName}}" />
   174              <RuleParameter Name="IsPersistent" Value="True" />
   175              <RuleParameter Name="Domain" Value="" />
   176              <RuleParameter Name="Index" Value="0" />
   177            </RuleParameters>
   178          </ValidationRule>
   179          <ValidationRule Classname="Dropthings.Test.Rules.CookieValidationRule, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Check Cookie From Response" Description="" Level="High" ExectuionOrder="BeforeDependents">
   180            <RuleParameters>
   181              <RuleParameter Name="StopOnError" Value="False" />
   182              <RuleParameter Name="CookieValueToMatch" Value="" />
   183              <RuleParameter Name="MatchValue" Value="False" />
   184              <RuleParameter Name="Exists" Value="False" />
   185              <RuleParameter Name="CookieName" Value="{{Config.TestParameters.SessionCookieName}}" />
   186              <RuleParameter Name="IsPersistent" Value="False" />
   187              <RuleParameter Name="Domain" Value="" />
   188              <RuleParameter Name="Index" Value="0" />
   189            </RuleParameters>
   190          </ValidationRule>
   191          <ValidationRule Classname="Dropthings.Test.Rules.CacheHeaderValidation, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Cache Header Validation" Description="" Level="High" ExectuionOrder="BeforeDependents">
   192            <RuleParameters>
   193              <RuleParameter Name="Enabled" Value="True" />
   194              <RuleParameter Name="DifferenceThresholdSec" Value="0" />
   195              <RuleParameter Name="CacheControlPrivate" Value="False" />
   196              <RuleParameter Name="CacheControlPublic" Value="False" />
   197              <RuleParameter Name="CacheControlNoCache" Value="True" />
   198              <RuleParameter Name="ExpiresAfterSeconds" Value="0" />
   199              <RuleParameter Name="StopOnError" Value="False" />
   200            </RuleParameters>
   201          </ValidationRule>
   202          <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   203            <RuleParameters>
   204              <RuleParameter Name="FindText" Value="How to of the Day" />
   205              <RuleParameter Name="IgnoreCase" Value="False" />
   206              <RuleParameter Name="UseRegularExpression" Value="False" />
   207              <RuleParameter Name="PassIfTextFound" Value="True" />
   208            </RuleParameters>
   209          </ValidationRule>
   210          <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   211            <RuleParameters>
   212              <RuleParameter Name="FindText" Value="Weather" />
   213              <RuleParameter Name="IgnoreCase" Value="False" />
   214              <RuleParameter Name="UseRegularExpression" Value="False" />
   215              <RuleParameter Name="PassIfTextFound" Value="True" />
   216            </RuleParameters>
   217          </ValidationRule>
   218          <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   219            <RuleParameters>
   220              <RuleParameter Name="FindText" Value="All rights reserved" />
   221              <RuleParameter Name="IgnoreCase" Value="False" />
   222              <RuleParameter Name="UseRegularExpression" Value="False" />
   223              <RuleParameter Name="PassIfTextFound" Value="True" />
   224            </RuleParameters>
   225          </ValidationRule>
   226        </ValidationRules>
   227      </Request>
   228      <TransactionTimer Name="Show Hide Widget List">
   229        <Items>
   230          <Comment CommentText="Show Widget List and expect Widget List to produce BBC Word widget link" />
   231          <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0.5" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   232            <ValidationRules>
   233              <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   234                <RuleParameters>
   235                  <RuleParameter Name="FindText" Value="BBC World" />
   236                  <RuleParameter Name="IgnoreCase" Value="False" />
   237                  <RuleParameter Name="UseRegularExpression" Value="False" />
   238                  <RuleParameter Name="PassIfTextFound" Value="True" />
   239                </RuleParameters>
   240              </ValidationRule>
   241            </ValidationRules>
   242            <RequestPlugins>
   243              <RequestPlugin Classname="Dropthings.Test.Plugin.AsyncPostbackRequestPlugin, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="AsyncPostbackRequestPlugin" Description="">
   244                <RuleParameters>
   245                  <RuleParameter Name="ControlName" Value="TabControlPanel$ShowAddContentPanel" />
   246                  <RuleParameter Name="UpdatePanelName" Value="{{$UPDATEPANEL.OnPageMenuUpdatePanel.1}}" />
   247                </RuleParameters>
   248              </RequestPlugin>
   249            </RequestPlugins>
   250          </Request>
   251          <Comment CommentText="Hide Widget List and expect the outpu does not have the BBC World Widget" />
   252          <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0.5" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   253            <ValidationRules>
   254              <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   255                <RuleParameters>
   256                  <RuleParameter Name="FindText" Value="TabControlPanel$ShowAddContentPanel" />
   257                  <RuleParameter Name="IgnoreCase" Value="False" />
   258                  <RuleParameter Name="UseRegularExpression" Value="False" />
   259                  <RuleParameter Name="PassIfTextFound" Value="True" />
   260                </RuleParameters>
   261              </ValidationRule>
   262            </ValidationRules>
   263            <RequestPlugins>
   264              <RequestPlugin Classname="Dropthings.Test.Plugin.AsyncPostbackRequestPlugin, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="AsyncPostbackRequestPlugin" Description="">
   265                <RuleParameters>
   266                  <RuleParameter Name="ControlName" Value="TabControlPanel$HideAddContentPanel" />
   267                  <RuleParameter Name="UpdatePanelName" Value="{{$UPDATEPANEL.OnPageMenuUpdatePanel.1}}" />
   268                </RuleParameters>
   269              </RequestPlugin>
   270            </RequestPlugins>
   271          </Request>
   272        </Items>
   273      </TransactionTimer>
   274      <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/API/Proxy.svc/ajax/GetRss?url=%22http%3A%2F%2Ffeeds.feedburner.com%2FOmarAlZabirBlog%22&amp;count=10&amp;cacheDuration=10" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   275        <ValidationRules>
   276          <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   277            <RuleParameters>
   278              <RuleParameter Name="FindText" Value="{&quot;d&quot;:[{&quot;__type&quot;:&quot;RssItem:#Dropthings.Web.Util&quot;" />
   279              <RuleParameter Name="IgnoreCase" Value="False" />
   280              <RuleParameter Name="UseRegularExpression" Value="False" />
   281              <RuleParameter Name="PassIfTextFound" Value="True" />
   282            </RuleParameters>
   283          </ValidationRule>
   284        </ValidationRules>
   285      </Request>
   286      <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/API/Proxy.svc/ajax/GetUrl?url=%22http%3A%2F%2Ffeeds.feedburner.com%2FOmarAlZabirBlog%22&amp;cacheDuration=10" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   287        <ValidationRules>
   288          <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   289            <RuleParameters>
   290              <RuleParameter Name="FindText" Value="&lt;channel&gt;" />
   291              <RuleParameter Name="IgnoreCase" Value="False" />
   292              <RuleParameter Name="UseRegularExpression" Value="False" />
   293              <RuleParameter Name="PassIfTextFound" Value="True" />
   294            </RuleParameters>
   295          </ValidationRule>
   296        </ValidationRules>
   297      </Request>
   298      <TransactionTimer Name="Edit Collapse Expand Widget">
   299        <Items>
   300          <Comment CommentText="Click edit on first widget &quot;How to of the Day&quot; and expect URL textbox to be present with Feed Url" />
   301          <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0.5" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   302            <ValidationRules>
   303              <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleRequiredAttributeValue, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Required Attribute Value" Description="Verifies the existence of a specified HTML tag that contains an attribute with a specified value." Level="High" ExectuionOrder="BeforeDependents">
   304                <RuleParameters>
   305                  <RuleParameter Name="TagName" Value="input" />
   306                  <RuleParameter Name="AttributeName" Value="value" />
   307                  <RuleParameter Name="MatchAttributeName" Value="" />
   308                  <RuleParameter Name="MatchAttributeValue" Value="" />
   309                  <RuleParameter Name="ExpectedValue" Value="http://www.wikihow.com/feed.rss" />
   310                  <RuleParameter Name="IgnoreCase" Value="False" />
   311                  <RuleParameter Name="Index" Value="-1" />
   312                </RuleParameters>
   313              </ValidationRule>
   314            </ValidationRules>
   315            <ExtractionRules>
   316              <ExtractionRule Classname="Dropthings.Test.Rules.ExtractFormElements, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" VariableName="" DisplayName="Extract Form Elements" Description="">
   317                <RuleParameters>
   318                  <RuleParameter Name="ContextParameterName" Value="" />
   319                </RuleParameters>
   320              </ExtractionRule>
   321            </ExtractionRules>
   322            <RequestPlugins>
   323              <RequestPlugin Classname="Dropthings.Test.Plugin.AsyncPostbackRequestPlugin, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="AsyncPostbackRequestPlugin" Description="">
   324                <RuleParameters>
   325                  <RuleParameter Name="ControlName" Value="{{$POSTBACK.EditWidget.1}}" />
   326                  <RuleParameter Name="UpdatePanelName" Value="{{$UPDATEPANEL.WidgetHeaderUpdatePanel.1}}" />
   327                </RuleParameters>
   328              </RequestPlugin>
   329            </RequestPlugins>
   330          </Request>
   331          <Comment CommentText="Change the Feed Count Dropdown list to 10 and expect 10 Feed Link controls are generated" />
   332          <Request Method="POST" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0.5" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   333            <ValidationRules>
   334              <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   335                <RuleParameters>
   336                  <RuleParameter Name="FindText" Value="FeedList_ctl09_FeedLink" />
   337                  <RuleParameter Name="IgnoreCase" Value="False" />
   338                  <RuleParameter Name="UseRegularExpression" Value="False" />
   339                  <RuleParameter Name="PassIfTextFound" Value="True" />
   340                </RuleParameters>
   341              </ValidationRule>
   342            </ValidationRules>
   343            <RequestPlugins>
   344              <RequestPlugin Classname="Dropthings.Test.Plugin.AsyncPostbackRequestPlugin, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="AsyncPostbackRequestPlugin" Description="">
   345                <RuleParameters>
   346                  <RuleParameter Name="ControlName" Value="{{$POSTBACK.CancelEditWidget.1}}" />
   347                  <RuleParameter Name="UpdatePanelName" Value="{{$UPDATEPANEL.WidgetHeaderUpdatePanel.1}}" />
   348                </RuleParameters>
   349              </RequestPlugin>
   350            </RequestPlugins>
   351            <FormPostHttpBody>
   352              <FormPostParameter Name="{{$INPUT.FeedUrl.1}}" Value="http://www.wikihow.com/feed.rss" RecordedValue="" CorrelationBinding="" UrlEncode="True" />
   353              <FormPostParameter Name="{{$SELECT.FeedCountDropDownList.1}}" Value="10" RecordedValue="" CorrelationBinding="" UrlEncode="True" />
   354            </FormPostHttpBody>
   355          </Request>
   356          <Comment CommentText="Delete the How to of the Day widget and expect it's not found from response" />
   357          <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0.5" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   358            <ValidationRules>
   359              <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   360                <RuleParameters>
   361                  <RuleParameter Name="FindText" Value="How to of the Day" />
   362                  <RuleParameter Name="IgnoreCase" Value="False" />
   363                  <RuleParameter Name="UseRegularExpression" Value="False" />
   364                  <RuleParameter Name="PassIfTextFound" Value="False" />
   365                </RuleParameters>
   366              </ValidationRule>
   367            </ValidationRules>
   368            <RequestPlugins>
   369              <RequestPlugin Classname="Dropthings.Test.Plugin.AsyncPostbackRequestPlugin, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="AsyncPostbackRequestPlugin" Description="">
   370                <RuleParameters>
   371                  <RuleParameter Name="ControlName" Value="{{$POSTBACK.CloseWidget.1}}" />
   372                  <RuleParameter Name="UpdatePanelName" Value="{{$UPDATEPANEL.WidgetHeaderUpdatePanel.1}}" />
   373                </RuleParameters>
   374              </RequestPlugin>
   375            </RequestPlugins>
   376          </Request>
   377        </Items>
   378      </TransactionTimer>
   379      <TransactionTimer Name="Add New Widget">
   380        <Items>
   381          <Comment CommentText="Show widget list and expect Digg to be there" />
   382          <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0.5" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   383            <ValidationRules>
   384              <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   385                <RuleParameters>
   386                  <RuleParameter Name="FindText" Value="Digg" />
   387                  <RuleParameter Name="IgnoreCase" Value="False" />
   388                  <RuleParameter Name="UseRegularExpression" Value="False" />
   389                  <RuleParameter Name="PassIfTextFound" Value="True" />
   390                </RuleParameters>
   391              </ValidationRule>
   392            </ValidationRules>
   393            <RequestPlugins>
   394              <RequestPlugin Classname="Dropthings.Test.Plugin.AsyncPostbackRequestPlugin, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="AsyncPostbackRequestPlugin" Description="">
   395                <RuleParameters>
   396                  <RuleParameter Name="ControlName" Value="TabControlPanel$ShowAddContentPanel" />
   397                  <RuleParameter Name="UpdatePanelName" Value="{{$UPDATEPANEL.OnPageMenuUpdatePanel.1}}" />
   398                </RuleParameters>
   399              </RequestPlugin>
   400            </RequestPlugins>
   401          </Request>
   402          <Comment CommentText="Add New Widget" />
   403          <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0.5" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   404            <ValidationRules>
   405              <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   406                <RuleParameters>
   407                  <RuleParameter Name="FindText" Value="Digg" />
   408                  <RuleParameter Name="IgnoreCase" Value="False" />
   409                  <RuleParameter Name="UseRegularExpression" Value="False" />
   410                  <RuleParameter Name="PassIfTextFound" Value="True" />
   411                </RuleParameters>
   412              </ValidationRule>
   413            </ValidationRules>
   414            <RequestPlugins>
   415              <RequestPlugin Classname="Dropthings.Test.Plugin.AsyncPostbackRequestPlugin, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="AsyncPostbackRequestPlugin" Description="">
   416                <RuleParameters>
   417                  <RuleParameter Name="ControlName" Value="{{$POSTBACK.AddWidget.1}}" />
   418                  <RuleParameter Name="UpdatePanelName" Value="{{$UPDATEPANEL.OnPageMenuUpdatePanel.1}}" />
   419                </RuleParameters>
   420              </RequestPlugin>
   421            </RequestPlugins>
   422          </Request>
   423          <Comment CommentText="Delete the newly added widget" />
   424          <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0.5" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   425            <ValidationRules>
   426              <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   427                <RuleParameters>
   428                  <RuleParameter Name="FindText" Value="How to of the Day" />
   429                  <RuleParameter Name="IgnoreCase" Value="False" />
   430                  <RuleParameter Name="UseRegularExpression" Value="False" />
   431                  <RuleParameter Name="PassIfTextFound" Value="False" />
   432                </RuleParameters>
   433              </ValidationRule>
   434            </ValidationRules>
   435            <RequestPlugins>
   436              <RequestPlugin Classname="Dropthings.Test.Plugin.AsyncPostbackRequestPlugin, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="AsyncPostbackRequestPlugin" Description="">
   437                <RuleParameters>
   438                  <RuleParameter Name="ControlName" Value="{{$POSTBACK.CloseWidget.1}}" />
   439                  <RuleParameter Name="UpdatePanelName" Value="{{$UPDATEPANEL.WidgetHeaderUpdatePanel.1}}" />
   440                </RuleParameters>
   441              </RequestPlugin>
   442            </RequestPlugins>
   443          </Request>
   444        </Items>
   445      </TransactionTimer>
   446      <Comment CommentText="Revisit and ensure the Digg widget exists and How to widget does not exist" />
   447      <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Default.aspx" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0.5" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="" ReportingName="">
   448        <ValidationRules>
   449          <ValidationRule Classname="Dropthings.Test.Rules.CookieValidationRule, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Check Cookie From Response" Description="" Level="High" ExectuionOrder="BeforeDependents">
   450            <RuleParameters>
   451              <RuleParameter Name="StopOnError" Value="False" />
   452              <RuleParameter Name="CookieValueToMatch" Value="" />
   453              <RuleParameter Name="MatchValue" Value="False" />
   454              <RuleParameter Name="Exists" Value="False" />
   455              <RuleParameter Name="CookieName" Value="{{Config.TestParameters.AnonCookieName}}" />
   456              <RuleParameter Name="IsPersistent" Value="True" />
   457              <RuleParameter Name="Domain" Value="" />
   458              <RuleParameter Name="Index" Value="0" />
   459            </RuleParameters>
   460          </ValidationRule>
   461          <ValidationRule Classname="Dropthings.Test.Rules.CookieValidationRule, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Check Cookie From Response" Description="" Level="High" ExectuionOrder="BeforeDependents">
   462            <RuleParameters>
   463              <RuleParameter Name="StopOnError" Value="False" />
   464              <RuleParameter Name="CookieValueToMatch" Value="" />
   465              <RuleParameter Name="MatchValue" Value="False" />
   466              <RuleParameter Name="Exists" Value="False" />
   467              <RuleParameter Name="CookieName" Value="{{Config.TestParameters.SessionCookieName}}" />
   468              <RuleParameter Name="IsPersistent" Value="False" />
   469              <RuleParameter Name="Domain" Value="" />
   470              <RuleParameter Name="Index" Value="0" />
   471            </RuleParameters>
   472          </ValidationRule>
   473          <ValidationRule Classname="Dropthings.Test.Rules.CacheHeaderValidation, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Cache Header Validation" Description="" Level="High" ExectuionOrder="BeforeDependents">
   474            <RuleParameters>
   475              <RuleParameter Name="Enabled" Value="True" />
   476              <RuleParameter Name="DifferenceThresholdSec" Value="0" />
   477              <RuleParameter Name="CacheControlPrivate" Value="False" />
   478              <RuleParameter Name="CacheControlPublic" Value="False" />
   479              <RuleParameter Name="CacheControlNoCache" Value="True" />
   480              <RuleParameter Name="ExpiresAfterSeconds" Value="0" />
   481              <RuleParameter Name="StopOnError" Value="False" />
   482            </RuleParameters>
   483          </ValidationRule>
   484          <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   485            <RuleParameters>
   486              <RuleParameter Name="FindText" Value="How to of the Day" />
   487              <RuleParameter Name="IgnoreCase" Value="False" />
   488              <RuleParameter Name="UseRegularExpression" Value="False" />
   489              <RuleParameter Name="PassIfTextFound" Value="False" />
   490            </RuleParameters>
   491          </ValidationRule>
   492          <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   493            <RuleParameters>
   494              <RuleParameter Name="FindText" Value="Digg" />
   495              <RuleParameter Name="IgnoreCase" Value="False" />
   496              <RuleParameter Name="UseRegularExpression" Value="False" />
   497              <RuleParameter Name="PassIfTextFound" Value="True" />
   498            </RuleParameters>
   499          </ValidationRule>
   500          <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExectuionOrder="BeforeDependents">
   501            <RuleParameters>
   502              <RuleParameter Name="FindText" Value="All rights reserved" />
   503              <RuleParameter Name="IgnoreCase" Value="False" />
   504              <RuleParameter Name="UseRegularExpression" Value="False" />
   505              <RuleParameter Name="PassIfTextFound" Value="True" />
   506            </RuleParameters>
   507          </ValidationRule>
   508        </ValidationRules>
   509      </Request>
   510      <Comment CommentText="- Logout and ensure Anon Cookie is set to expire" />
   511      <Request Method="GET" Version="1.1" Url="{{Config.TestParameters.ServerURL}}/Logout.ashx" ThinkTime="0" Timeout="300" ParseDependentRequests="False" FollowRedirects="False" RecordResult="True" Cache="False" ResponseTimeGoal="0.5" Encoding="utf-8" ExpectedHttpStatusCode="302" ExpectedResponseUrl="" ReportingName="">
   512        <ValidationRules>
   513          <ValidationRule Classname="Dropthings.Test.Rules.CookieSetToExpire, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Ensure Cookie Set to Expire" Description="" Level="High" ExectuionOrder="BeforeDependents">
   514            <RuleParameters>
   515              <RuleParameter Name="CookieName" Value="{{Config.TestParameters.AnonCookieName}}" />
   516              <RuleParameter Name="Domain" Value="" />
   517              <RuleParameter Name="StopOnError" Value="False" />
   518            </RuleParameters>
   519          </ValidationRule>
   520        </ValidationRules>
   521      </Request>
   522    </Items>
   523    <DataSources>
   524      <DataSource Name="Config" Provider="Microsoft.VisualStudio.TestTools.DataSource.XML" Connection="|DataDirectory|\Config\TestParameters.xml">
   525        <Tables>
   526          <DataSourceTable Name="TestParameters" SelectColumns="SelectOnlyBoundColumns" AccessMethod="Sequential" />
   527        </Tables>
   528      </DataSource>
   529    </DataSources>
   530    <ValidationRules>
   531      <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidateResponseUrl, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Response URL" Description="Validates that the response URL after redirects are followed is the same as the recorded response URL.  QueryString parameters are ignored." Level="Low" ExectuionOrder="BeforeDependents" />
   532    </ValidationRules>
   533    <WebTestPlugins>
   534      <WebTestPlugin Classname="Dropthings.Test.Plugin.ASPNETWebTestPlugin, Dropthings.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="ASPNETWebTestPlugin" Description="" />
   535    </WebTestPlugins>
   536  </WebTest>
   537  `)
   538  

View as plain text