[Webtest] How to print/log in WebTest? + dbUnit to Webtest traverse update

webtest@lists.canoo.com webtest@lists.canoo.com
Thu, 13 Jul 2006 12:08:09 -0400


----------MailBlocks_8C874ADAAE93C1D_15B4_4B20_FWM-R15.sysops.aol.com
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

Rob,
 
Thanks for the suggestion. I, too, had no luck getting diagnostics with echo but was hoping it was operator error :(
 
I'm going to take a look at your idea.
 
Doug 
 
 
-----Original Message-----
From: canoo@rob.manthey.id.au
To: webtest@lists.canoo.com
Sent: Wed, 12 Jul 2006 7:56 PM
Subject: Re: [Webtest] How to print/log in WebTest? + dbUnit to Webtest traverse update


Not sure if this answers your question but here's a patch from what I'm working on - it extracts some values from a dbUnit xml file and stores them in WebtestProperties and then uses them to test rendered content in the webpage.  As an aside, I logged to a local file (which is what you were asking about), as I had no luck getting diagnostic feedback from either echo or print.

my steps:

<groovy>
    def logFile = new File('./webtest.log')
    logFile.append("\nTest Start\n")
    
    def testData = new XmlParser().parse( new File('../../config/InHouseTesting.xml') )
    
    def customerId = 1001
    
    def testCustomer = testData.customerDetails.find{it['@customerID']==customerId}
    def testCustomerId = testCustomer.'@customerID'
    def testCustomerName = testCustomer.'@customerName'
    logFile.append("${testCustomerId} - ${testCustomerName}")
    // I can't get groovy's print to appear - some classpath dilemma no doubt
    // print "${testCustomerId} - ${testCustomerName}"
    
    step.setWebtestProperty('test_customer_id', testCustomerId)
    step.setWebtestProperty('test_customer_name', testCustomerName)    
    
    logFile.append("\nTest End\n")
</groovy>

<verifyProperty name="test_customer_id" text="1001" />
<verifyProperty name="test_customer_name" text="Canoo WebTest Customer 1" />

<verifyText description="dbUnit text must be present in the current webpage"
   text="#{test_customer_name}" />
   
<!-- these don't render the properties properly - I don't know why not? -->
<echo message="Test Customer Name = ${test_customer_name}" />
<echo message="Test Customer Name = #{test_customer_name}" />


Here's a sample chopped down from the dbUnit file (standard dbUnit file that loads xml into db for testing)


<?xml version='1.0' encoding='UTF-8'?>
<dataset>
 <customerDetails customerID="1001" customerName="Canoo WebTest Customer 1" contactName="Contact Name 1" contactAddress="1 Address St" />
 <customerDetails customerID="1002" customerName="Canoo WebTest Customer 2" contactName="Contact Name 2" contactAddress="2 Address St" />
 <customerDetails customerID="1003" customerName="Canoo WebTest Customer 3" contactName="Contact Name 3" contactAddress="3 Address St" />
 <customerDetails customerID="1004" customerName="Canoo WebTest Customer 4" contactName="Contact Name 4" contactAddress="4 Address St" />
 
 <userDetails username="webtest01" customerID="1001" fullName="WebTest User" userTypeSystem="user" />
 <userDetails username="webtest02" customerID="1001" fullName="WebTest Administrator" userTypeSystem="administrator" />

 <siteDetails siteID="1001" customerID="1001" siteName="Site 1001" />
 <siteDetails siteID="1002" customerID="1001" siteName="Site 1002" />
 <siteDetails siteID="1003" customerID="1001" siteName="Site 1003" />
</dataset>


on 13/07/06 01:46 dlundin@aol.com said the following: 
Hello,
 
I've done some poking around on the site but haven't found an answer to this question ... 
 
I'm using storeXPath to save a value into a property. Now, how to I print/log it in an output file? I've seen reference that such logging is possible.
 
Thanks in advance
Doug


Check out AOL.com today. Breaking news, video search, pictures, email and IM. All on demand. Always Free.
________________________________________________________________________
Check out AOL.com today. Breaking news, video search, pictures, email and IM. All on demand. Always Free.

----------MailBlocks_8C874ADAAE93C1D_15B4_4B20_FWM-R15.sysops.aol.com
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: 7bit

<HTML><BODY>
<div>Rob,</div>


<div>&nbsp;</div>


<div>Thanks for the suggestion. I, too, had no luck getting diagnostics with echo but was hoping it was operator error :(</div>


<div>&nbsp;</div>


<div>I'm going to take a look at your idea.</div>


<div>&nbsp;</div>


<div>Doug&nbsp;</div>


<div>&nbsp;</div>
&nbsp;<br>
-----Original Message-----<br>
From: canoo@rob.manthey.id.au<br>
To: webtest@lists.canoo.com<br>
Sent: Wed, 12 Jul 2006 7:56 PM<br>
Subject: Re: [Webtest] How to print/log in WebTest? + dbUnit to Webtest traverse update<br>
<br>

<STYLE>
.AOLPlainTextBody {
    margin: 0px;
    font-family: Tahoma, Verdana, Arial, Sans-Serif;
    font-size: 12px; 
    color: #000; 
    background-color: #fff; 
}

.AOLPlainTextBody pre {
    font-size: 9pt;
}

.AOLInlineAttachment {
    margin: 10px;
}

.AOLAttachmentHeader {
    font: 11px arial;
    border: 1px solid #7DA8D4;
    background: #F9F9F9;
}

.AOLAttachmentHeader .Title {
    font: 11px arial;
    background: #B5DDFA;
    padding: 3px 3px 3px 3px;
}

.AOLAttachmentHeader .FieldLabel {
    font: 11px arial; 
    color: #000000;
    padding: 1px 10px 1px 9px;
    background: #F9F9F9;
}

.AOLAttachmentHeader .FieldValue {
    font: 11px arial; 
    color: #000000;
    background: #F9F9F9;
}

.AOLAttachmentHeader a, .AOLImage a {
    color: #2864B4;
    text-decoration: none;
}

.AOLAttachmentHeader a:hover, .AOLImage a:hover {
    color: #2864B4;
    text-decoration: underline;
}

body {
    background-color: white;
    font-family: "Verdana";
    font-size: 10pt;
    border: 0px;
}

.spell {
    padding-bottom:2px;
    background:yellow url(images/bg_spellingErr.gif) bottom left repeat-x;
    color:#000;
}

.spellHover {
    text-decoration:none;
    color:#b00;
    padding-bottom:2px;
    background:yellow url(images/bg_spellingErr.gif) bottom left repeat-x;
}

p {
    margin: 0px;
    padding: 0px;
}

img.managedImg {
    width: 0px;
    height: 0px;
}

img.placeholder {
    width: 275px;
    height: 206px;
    background: #F4F4F4 url(images/activityIndicator.gif) center center no-repeat;
    border: 1px solid #DADAD6 !important;  
}

</STYLE>


<div id=AOLMsgPart_2_e6240d27-3664-4af1-a432-2d959cc62afe>Not sure if this answers your question but here's a patch from what I'm working on - it extracts some values from a dbUnit xml file and stores them in WebtestProperties and then uses them to test rendered content in the webpage.&nbsp; As an aside, I logged to a local file (which is what you were asking about), as I had no luck getting diagnostic feedback from either echo or print.<br>
<br>
my steps:<br>
<PRE>&lt;groovy&gt;
&nbsp;&nbsp;&nbsp; def logFile = new File('./webtest.log')
&nbsp;&nbsp;&nbsp; logFile.append("\nTest Start\n")
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; def testData = new XmlParser().parse( new File('../../config/InHouseTesting.xml') )
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; def customerId = 1001
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; def testCustomer = testData.customerDetails.find{it['@customerID']==customerId}
&nbsp;&nbsp;&nbsp; def testCustomerId = testCustomer.'@customerID'
&nbsp;&nbsp;&nbsp; def testCustomerName = testCustomer.'@customerName'
&nbsp;&nbsp;&nbsp; logFile.append("${testCustomerId} - ${testCustomerName}")
&nbsp;&nbsp;&nbsp; // I can't get groovy's print to appear - some classpath dilemma no doubt
&nbsp;&nbsp;&nbsp; // print "${testCustomerId} - ${testCustomerName}"
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; step.setWebtestProperty('test_customer_id', testCustomerId)
&nbsp;&nbsp;&nbsp; step.setWebtestProperty('test_customer_name', testCustomerName)&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; logFile.append("\nTest End\n")
&lt;/groovy&gt;

&lt;verifyProperty name="test_customer_id" text="1001" /&gt;
&lt;verifyProperty name="test_customer_name" text="Canoo WebTest Customer 1" /&gt;

&lt;verifyText description="dbUnit text must be present in the current webpage"
&nbsp;&nbsp; text="#{test_customer_name}" /&gt;
&nbsp;&nbsp; 
&lt;!-- these don't render the properties properly - I don't know why not? --&gt;
&lt;echo message="Test Customer Name = ${test_customer_name}" /&gt;
&lt;echo message="Test Customer Name = #{test_customer_name}" /&gt;
</PRE><br>
Here's a sample chopped down from the dbUnit file (standard dbUnit file that loads xml into db for testing)<br>
<br>
<PRE>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
&lt;dataset&gt;
 &lt;customerDetails customerID="1001" customerName="Canoo WebTest Customer 1" contactName="Contact Name 1" contactAddress="1 Address St" /&gt;
&nbsp;&lt;customerDetails customerID="1002" customerName="Canoo WebTest Customer 2" contactName="Contact Name 2" contactAddress="2 Address St" /&gt;
 &lt;customerDetails customerID="1003" customerName="Canoo WebTest Customer 3" contactName="Contact Name 3" contactAddress="3 Address St" /&gt;
&nbsp;&lt;customerDetails customerID="1004" customerName="Canoo WebTest Customer 4" contactName="Contact Name 4" contactAddress="4 Address St" /&gt;
 
 &lt;userDetails username="webtest01" customerID="1001" fullName="WebTest User" userTypeSystem="user" /&gt;
 &lt;userDetails username="webtest02" customerID="1001" fullName="WebTest Administrator" userTypeSystem="administrator" /&gt;

 &lt;siteDetails siteID="1001" customerID="1001" siteName="Site 1001" /&gt;
 &lt;siteDetails siteID="1002" customerID="1001" siteName="Site 1002" /&gt;
 &lt;siteDetails siteID="1003" customerID="1001" siteName="Site 1003" /&gt;
&lt;/dataset&gt;</PRE><br>
<br>
on 13/07/06 01:46 <A class=moz-txt-link-abbreviated href="javascript:parent.ComposeTo('dlundin@aol.com');">dlundin@aol.com</A> said the following: 
<BLOCKQUOTE cite=mid8C873E185819F59-63C-6C9D@FWM-R10.sysops.aol.com type="cite">

<div>Hello,</div>


<div>&nbsp;</div>


<div>I've done some poking around on the site but haven't found an answer to this question ... </div>


<div>&nbsp;</div>


<div>I'm using <FONT size=2>storeXPath to save a value into a property. Now, how to I print/log it in an output file? I've seen reference that such logging is possible.</FONT></div>


<div>&nbsp;</div>


<div>Thanks in advance</div>


<div>Doug</div>


<div class=AOLPromoFooter>
<HR style="MARGIN-TOP: 10px">
<A href="http://pr.atwola.com/promoclk/1615326657x4311227241x4298082137/aol?redir=http%3A%2F%2Fwww%2Eaol%2Ecom" target=_blank><B>Check out AOL.com today</B></A>. Breaking news, video search, pictures, email and IM. All on demand. Always Free.<br>
</div>
</BLOCKQUOTE></div>
<!-- end of AOLMsgPart_2_e6240d27-3664-4af1-a432-2d959cc62afe --></BODY></HTML>

----------MailBlocks_8C874ADAAE93C1D_15B4_4B20_FWM-R15.sysops.aol.com--