Support for NormalizeXml on XHTML pages
---------------------------------------

         Key: WT-528
         URL: http://webtest-community.canoo.com/jira/browse/WT-528
     Project: WebTest
        Type: New Feature

    Versions: 2.6    
    Reporter: Ian Homer


The NormalizeXml filter only applies the filter to pages of class 
"com.gargoylesoftware.htmlunit.xml.XmlPage" - and gives the warning "WARN : 
Ignoring non-XML response (com.canoo.webtest.extension.NormalizeXmlFilter)".  

We are using a canoo test which checks whether a couple of pages have changed 
at all for a variety of user agents.  We use this in build process to check 
that control pages are delivered as expected from our product.   The 
verifyContent task allows us to do this verification, but if there is any delta 
in the file then the report reports the full contents of the expected XHTML 
file and the actual XHTML file because our product has optimised the XHTML by 
removing line breaks.  If we could normalise the XHTML (as NormalizeXml does 
for XML) prior to doing the verifyContent then the markup would be indented and 
have line breaks included making the diff report much clearer allowing us to 
focus in on the particular regression issue.

The test case we currently have is below (apologies, but this class has 
external deps which aren't included, but I hope it paints enough of a picture)

class ExpectContentTest extends BemokoWebtest {
  def log = LogFactory.getLog(ExpectContentTest.class)
  static expectDir = "src/test/resources/com/bemoko/webtest/live/expect"
  
  void test() {
    def uris=["/welcome/main.css","/welcome/hello"]    
    uris.each { uri ->
      new HeroDevices().all.toList().each { deviceData -> 
        def expect=new ExpectFile(uri,deviceData.id,expectDir)
        webtest("ExpectContentTest : $uri : ${profile} : ${deviceData.id}") {
          config(liveConfig) {
            deviceData.evidence.each() {
              header(name:it.key, value:it.value)             
            }
          }
          invoke uri, description: "$uri : ${profile} : ${deviceData.id}"
          groovy {
            if (!expect.file.exists()) {
              
expect.autoCreate(step.context.currentResponse.webResponse.contentAsString)
            }            
          }
          verifyContent(referenceFile: "${expect.filename}") {
                // normalizeXml isn't enabled for HtmlPage (only XmlPage) 
                // normalizeXml();
                // Support live deployed on "/live" context and root context
                replaceFilter regex:'/live/welcome/',replacement:'/welcome/'
          }
        }       
      }
    }
  }
}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://webtest-community.canoo.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to