You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by yaroslav1 <sl...@yahoo.com> on 2008/12/31 23:13:33 UTC

how to "assert" a whole html page with some dynamic content

Hi,

First for all - Happy New Year everyboby!

Here is a problem which I cannot solve a few days... :(

I'm trying to check a whole html page with some dynamic content.
My approach is like:
1) make http-request;
2) by using regular-expression-extractor to create those variables (related
to the dynamic content);
3) usu response-assertion (with selected "Text Response" and "Equal"), into
"patterns to test" - copy-paste the full page from a response of the step
1), and to replace the dynamic content by variables from
regular-expression-extractors.

But this is does not work as expected.
I do understand that you shoul not to "debug" my test-plan, but this is the
best way to provide details.
Here is my simple test-plan (I've also attached as a file) - what is wrong?
-------------
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.1">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test
Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables"
elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments"
testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup"
testname="Thread Group" enabled="true">
        <elementProp name="ThreadGroup.main_controller"
elementType="LoopController" guiclass="LoopControlPanel"
testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">1</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <longProp name="ThreadGroup.start_time">1228863671000</longProp>
        <longProp name="ThreadGroup.end_time">1228863671000</longProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <CookieManager guiclass="CookiePanel" testclass="CookieManager"
testname="HTTP Cookie Manager" enabled="true">
          <collectionProp name="CookieManager.cookies"/>
          <boolProp name="CookieManager.clearEachIteration">true</boolProp>
          <stringProp name="CookieManager.policy">rfc2109</stringProp>
        </CookieManager>
        <hashTree/>
        <ConfigTestElement guiclass="HttpDefaultsGui"
testclass="ConfigTestElement" testname="HTTP Request Defaults"
enabled="true">
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments"
guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined
Variables" enabled="true">
            <collectionProp name="Arguments.arguments"/>
          </elementProp>
          <stringProp
name="HTTPSampler.domain">gonew.warrantysupport.net</stringProp>
          <stringProp name="HTTPSampler.port"></stringProp>
          <stringProp name="HTTPSampler.protocol"></stringProp>
          <stringProp name="HTTPSampler.contentEncoding"></stringProp>
          <stringProp name="HTTPSampler.path"></stringProp>
        </ConfigTestElement>
        <hashTree/>
        <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer"
testname="Constant Timer" enabled="true">
          <stringProp name="ConstantTimer.delay">1000</stringProp>
        </ConstantTimer>
        <hashTree/>
        <HTTPSampler guiclass="HttpTestSampleGui" testclass="HTTPSampler"
testname="HTTP - root page" enabled="true">
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments"
guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined
Variables" enabled="true">
            <collectionProp name="Arguments.arguments"/>
          </elementProp>
          <stringProp name="HTTPSampler.domain"></stringProp>
          <stringProp name="HTTPSampler.port"></stringProp>
          <stringProp name="HTTPSampler.protocol"></stringProp>
          <stringProp name="HTTPSampler.contentEncoding"></stringProp>
          <stringProp name="HTTPSampler.path">/</stringProp>
          <stringProp name="HTTPSampler.method">GET</stringProp>
          <boolProp name="HTTPSampler.follow_redirects">false</boolProp>
          <boolProp name="HTTPSampler.auto_redirects">true</boolProp>
          <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
          <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
          <stringProp name="HTTPSampler.FILE_NAME"></stringProp>
          <stringProp name="HTTPSampler.FILE_FIELD"></stringProp>
          <stringProp name="HTTPSampler.mimetype"></stringProp>
          <stringProp name="HTTPSampler.monitor">false</stringProp>
          <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
        </HTTPSampler>
        <hashTree>
          <RegexExtractor guiclass="RegexExtractorGui"
testclass="RegexExtractor" testname="Regular Expression Extractor"
enabled="true">
            <stringProp name="RegexExtractor.useHeaders">false</stringProp>
            <stringProp name="RegexExtractor.refname">ACTION</stringProp>
            <stringProp name="RegexExtractor.regex">&lt;form
id=&quot;LoginForm&quot; name=&quot;LoginForm&quot; method=&quot;post&quot;
action=&quot;login.aspx\?__ufps=(.+?)&amp;AspxAutoDetectCookieSupport=1&quot;&gt;</stringProp>
            <stringProp name="RegexExtractor.template">$1$</stringProp>
            <stringProp name="RegexExtractor.default">bad</stringProp>
            <stringProp name="RegexExtractor.match_number">1</stringProp>
          </RegexExtractor>
          <hashTree/>
          <RegexExtractor guiclass="RegexExtractorGui"
testclass="RegexExtractor" testname="Regular Expression Extractor"
enabled="true">
            <stringProp name="RegexExtractor.useHeaders">false</stringProp>
            <stringProp name="RegexExtractor.refname">VIEWSTATE</stringProp>
            <stringProp name="RegexExtractor.regex">&lt;input
type=&quot;hidden&quot; name=&quot;__VIEWSTATE&quot;
value=&quot;(.+?)&quot;&gt;</stringProp>
            <stringProp name="RegexExtractor.template">$1$</stringProp>
            <stringProp name="RegexExtractor.default">bad</stringProp>
            <stringProp name="RegexExtractor.match_number">1</stringProp>
          </RegexExtractor>
          <hashTree/>
          <RegexExtractor guiclass="RegexExtractorGui"
testclass="RegexExtractor" testname="Regular Expression Extractor"
enabled="true">
            <stringProp name="RegexExtractor.useHeaders">false</stringProp>
            <stringProp name="RegexExtractor.refname">LINK</stringProp>
            <stringProp name="RegexExtractor.regex">        - &lt;a
href=&quot;login.aspx\?__VIEWSTATE=(.+?)&amp;</stringProp>
            <stringProp name="RegexExtractor.template">$1$</stringProp>
            <stringProp name="RegexExtractor.default">bad</stringProp>
            <stringProp name="RegexExtractor.match_number">1</stringProp>
          </RegexExtractor>
          <hashTree/>
          <ResponseAssertion guiclass="AssertionGui"
testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
            <collectionProp name="Asserion.test_strings">
              <stringProp name="-1509407321">&lt;!DOCTYPE html PUBLIC
&quot;-//W3C//DTD XHTML Mobile 1.0//EN&quot;
&quot;http://www.wapforum.org/DTD/xhtml-mobile10.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;goNEW&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
${ACTION_g0}
${VIEWSTATE_g0}
&lt;div align=&quot;Center&quot;&gt;&lt;img
src=&quot;/(X(1))/Images/goNEW.gif&quot; alt=&quot;NEW&quot;
border=&quot;0&quot; /&gt;&lt;/div&gt;
        Email Address:&lt;br&gt;
&lt;input name=&quot;tbEmailAddress&quot; size=&quot;8&quot;/&gt;
            @&lt;select
name=&quot;loginValidEmailGroup$ctl00$drpEmails&quot;
id=&quot;loginValidEmailGroup_ctl00_drpEmails&quot;&gt;
	&lt;option value=&quot;newcorp.com&quot;&gt;newcorp.com&lt;/option&gt;
	&lt;option
value=&quot;servicebench.com&quot;&gt;servicebench.com&lt;/option&gt;
	&lt;option value=&quot;waca.com&quot;&gt;waca.com&lt;/option&gt;

&lt;/select&gt;&lt;span
id=&quot;loginValidEmailGroup_ctl00_lblBr&quot;&gt;&lt;br/&gt;&lt;/span&gt;
       

         
        Password:&lt;br&gt;
&lt;input name=&quot;tbPassword&quot;
type=&quot;password&quot;/&gt;&lt;br&gt;
&lt;input name=&quot;btnSignIn&quot; type=&quot;submit&quot;
value=&quot;Sign In&quot;/&gt;&lt;br&gt;

        
        &lt;br&gt;

${LINK_g0}__ET=ctl04&amp;__EA=registerForm&amp;__ufps=&amp;AspxAutoDetectCookieSupport=1&quot;&gt;I
need to register &lt;/a&gt;&lt;br&gt;

${LINK_g0}__ET=ctl06&amp;__EA=passwordForm&amp;__ufps=&amp;AspxAutoDetectCookieSupport=1&quot;&gt;I
forgot my password &lt;/a&gt;&lt;br&gt;

${LINK_g0}__ET=ctl08&amp;__EA=feedbackAboutForm&amp;__ufps=&amp;AspxAutoDetectCookieSupport=1&quot;&gt;Feedback
&amp;amp; about
&lt;/a&gt;&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;</stringProp>
            </collectionProp>
            <stringProp
name="Assertion.test_field">Assertion.response_data</stringProp>
            <stringProp name="Assertion.assume_success">false</stringProp>
            <intProp name="Assertion.test_type">8</intProp>
          </ResponseAssertion>
          <hashTree/>
        </hashTree>
        <ResultCollector guiclass="ViewResultsFullVisualizer"
testclass="ResultCollector" testname="View Results Tree" enabled="true">
          <boolProp name="ResultCollector.error_logging">false</boolProp>
          <objProp>
            <name>saveConfig</name>
            <value class="SampleSaveConfiguration">
              <time>true</time>
              <latency>true</latency>
              <timestamp>true</timestamp>
              <success>true</success>
              <label>true</label>
              <code>true</code>
              <message>true</message>
              <threadName>true</threadName>
              <dataType>true</dataType>
              <encoding>false</encoding>
              <assertions>true</assertions>
              <subresults>true</subresults>
              <responseData>false</responseData>
              <samplerData>false</samplerData>
              <xml>true</xml>
              <fieldNames>false</fieldNames>
              <responseHeaders>false</responseHeaders>
              <requestHeaders>false</requestHeaders>
              <responseDataOnError>false</responseDataOnError>
             
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
              <assertionsResultsToSave>0</assertionsResultsToSave>
              <bytes>true</bytes>
            </value>
          </objProp>
          <stringProp name="filename"></stringProp>
        </ResultCollector>
        <hashTree/>
        <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler"
testname="Debug Sampler" enabled="true">
          <boolProp name="displayJMeterProperties">false</boolProp>
          <boolProp name="displayJMeterVariables">true</boolProp>
          <boolProp name="displaySystemProperties">false</boolProp>
        </DebugSampler>
        <hashTree/>
        <ResultCollector guiclass="AssertionVisualizer"
testclass="ResultCollector" testname="Assertion Results" enabled="true">
          <boolProp name="ResultCollector.error_logging">false</boolProp>
          <objProp>
            <name>saveConfig</name>
            <value class="SampleSaveConfiguration">
              <time>true</time>
              <latency>true</latency>
              <timestamp>true</timestamp>
              <success>true</success>
              <label>true</label>
              <code>true</code>
              <message>true</message>
              <threadName>true</threadName>
              <dataType>true</dataType>
              <encoding>false</encoding>
              <assertions>true</assertions>
              <subresults>true</subresults>
              <responseData>false</responseData>
              <samplerData>false</samplerData>
              <xml>true</xml>
              <fieldNames>false</fieldNames>
              <responseHeaders>false</responseHeaders>
              <requestHeaders>false</requestHeaders>
              <responseDataOnError>false</responseDataOnError>
             
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
              <assertionsResultsToSave>0</assertionsResultsToSave>
              <bytes>true</bytes>
            </value>
          </objProp>
          <stringProp name="filename"></stringProp>
        </ResultCollector>
        <hashTree/>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>
---------------------



http://www.nabble.com/file/p21237485/test.jmx test.jmx 
-- 
View this message in context: http://www.nabble.com/how-to-%22assert%22-a-whole-html-page-with-some-dynamic-content-tp21237485p21237485.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: how to "assert" a whole html page with some dynamic content

Posted by sebb <se...@gmail.com>.
On 31/12/2008, yaroslav1 <sl...@yahoo.com> wrote:
>
>  Hi,
>
>  First for all - Happy New Year everyboby!
>
>  Here is a problem which I cannot solve a few days... :(
>
>  I'm trying to check a whole html page with some dynamic content.

That is going to be tricky and expensive - is it really necessary to
check everything?

I suggest you just check a few important parts of the page in the test itself.
If you really want to check the full page, use the Save Responses to a
File element to create a file with the full details and compare that
separately after the test has finished.

>  My approach is like:
>  1) make http-request;
>  2) by using regular-expression-extractor to create those variables (related
>  to the dynamic content);
>  3) usu response-assertion (with selected "Text Response" and "Equal"), into
>  "patterns to test" - copy-paste the full page from a response of the step
>  1), and to replace the dynamic content by variables from
>  regular-expression-extractors.
>  But this is does not work as expected.

Probably because of line endings.

If you really want to debug this, then save the HTML to a file, and
create a test plan using an HTTP sampler with the "file" protocol.

You can then re-run the test as often as you want, and gradually
refine the RE to do what you want.

Start with a short section using "Contains" and gradually add more to
the RE. Switch to "Equal" at the very end.

>  I do understand that you shoul not to "debug" my test-plan, but this is the
>  best way to provide details
>  Here is my simple test-plan (I've also attached as a file) - what is wrong?

Please don't send attachments or large includes to the list.

<snip/>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org