You should upgrade to at least R_1346:

BUILD COMPLETE - R_1346
Date of build   06/14/2006 01:30:39
Last log entry  WT-168 compareToExpected plays with binary files better now

Cheers, Paul.

Rob Manthey wrote:
My version is 2.0_R_1217
I suspect that I have some peculiar classpath problem which is being masked by an inaccurate error message ... my version of that test:

-------------------------------------------------------------

  <target name="main">

      <property name="expectedFile" location="savedLogo.gif"/>

<property name="testUrl" value="http://www.asert.com.au/images/ASERT_logo_white_on_midnightblue_sml.gif"/>

<!-- <property name="testUrl" value="http://www.asert.com.au/images/asert_slogo_welcome.gif"/> -->

      <webtest name="compare jpeg">

           &testconfig;

           <steps>

               <echo message="before ${testUrl}"/>

               <invoke description="Request image" url="${testUrl}" />

<!-- Compare the current response with the expected value. -->

               <echo message="during ${expectedFile}"/>

               <compareToExpected toFile="${expectedFile}" />

               <echo message="after"/>

           </steps>

       </webtest>

   </target>

-------------------------------------------------------------

... and the results:

-------------------------------------------------------------

[EMAIL PROTECTED] webtests]$ ant -f testSiteHistoryPeriodic.xml main

Buildfile: testSiteHistoryPeriodic.xml

Trying to override old definition of task sleep

main:

[echo] before http://www.asert.com.au/images/ASERT_logo_white_on_midnightblue_sml.gif

[echo] during /home/robertm/projects/t3000/code/v3-1/code_eclipse/cvs/root/t3000/server/test/webtests/savedLogo.gif

BUILD FAILED

/home/robertm/projects/t3000/code/v3-1/code_eclipse/cvs/root/t3000/server/test/webtests/testSiteHistoryPeriodic.xml:550: Canoo Webtest: R_1217.

Test failed.

Test step compareToExpected (/home/robertm/projects/t3000/code/v3-1/code_eclipse/cvs/root/t3000/server/test/webtests/testSiteHistoryPeriodic.xml:557: ) named "<unknown>" failed with message "<unknown>: **** The current response and the expected result file '/home/robertm/projects/t3000/code/v3-1/code_eclipse/cvs/root/t3000/server/test/webtests/savedLogo.gif' differ.

Binary files Differ: /home/robertm/projects/t3000/code/v3-1/code_eclipse/cvs/root/t3000/server/test/webtests/tmp1 and /home/robertm/projects/t3000/code/v3-1/code_eclipse/cvs/root/t3000/server/test/webtests/tmp2

"

Total time: 7 seconds

-------------------------------------------------------------

Now if I cut and paste those two echoed filespecs into Firefox, the browser shows matching ASERT logos and Beyond Compare calls them matched. And if I compare them using com.jj.javadiff.Diff in a groovy file as per ... (code googled from the com.jj.javadiff.Diff API web site)

-------------------------------------------------------------

print "\ndiff.start\n"

// Construct the diff object

com.jj.javadiff.Diff diff = new com.jj.javadiff.Diff();

// Supply the two files or directories to compare

diff.SetFirstFile("./savedLogo.gif");

diff.SetSecondFile("./ASERT_logo_white_on_midnightblue_sml.gif");

// Set the output stream for reporting differences

// Here we are asking for the output to go to standard out.

java.io.PrintWriter pw = new java.io.PrintWriter(System.out);

diff.SetWriter(pw);

// Perform the comparison

diff.Compare();

// Get the return status

print "diff.GetComparisonStatus() = ${diff.GetComparisonStatus()} -> "

switch (diff.GetComparisonStatus())

{

   case diff.COMPARISON_FILES_IDENTICAL:       // The files match exactly

       print "diff.COMPARISON_FILES_IDENTICAL"

       break;

   case diff.COMPARISON_FILES_DIFFER:          // The files differ

       print "diff.COMPARISON_FILES_DIFFER"

       break;

case diff.COMPARISON_FIRST_FILE_NOT_FOUND: // The first file was not found

       print "diff.COMPARISON_FIRST_FILE_NOT_FOUND"

       break;

case diff.COMPARISON_SECOND_FILE_NOT_FOUND: // The second file was not found

       print "diff.COMPARISON_SECOND_FILE_NOT_FOUND"

       break;

case diff.COMPARISON_UNKNOWN: // The comparison status is unknown

       print "diff.COMPARISON_UNKNOWN"

       break;

default: // The comparison status is confused

       print "diff.UNKNOWN"

       break;

   }

print "\ndiff.done\n"

// Flush the output buffer

pw.flush();

pw.close();

-------------------------------------------------------------

I get ...

-------------------------------------------------------------

[EMAIL PROTECTED] webtests]$ groovy file_compare.groovy

diff.start
diff.GetComparisonStatus() = 0 -> diff.COMPARISON_FILES_IDENTICAL
diff.done
[EMAIL PROTECTED] webtests]$

-------------------------------------------------------------

That's run from the same folder, same classpath, same env variables (same console window).

Incidentally my other tests have "testSpec" where you are using "webtest" markup tags ...? Has something changed in the dtd?
Perhaps we might have to look in my &testconfig; for more clues?
And finally, that first pass download seemed to work in that it saved a file in the local directory with the right name, but all available "open as" options in RH EL4 committed hari kari rather than open that file, and one of them reported that the file was probably corrupted just before dying. Subsequently I manually saved a copy from firefox into that location and that is the one that i used to do that above test runs ...

Thanks for the tips.
Rob


on 19/07/06 14:03 Paul King said the following:

Hi Rob,

This is supposed to work out of the box.
The following works for me:

   <target name="main">
       <property name="expectedFile" location="savedLogo.gif"/>
<property name="testUrl" value="http://www.asert.com.au/images/ASERT_logo_white_on_midnightblue_sml.gif"/> <!-- <property name="testUrl" value="http://www.asert.com.au/images/asert_slogo_welcome.gif"/> -->
       <webtest name="compare jpeg">
            &sharedConfig;
            <steps>
                <invoke description="Request image" url="${testUrl}" />
<!-- Compare the current response with the expected value. -->
                <compareToExpected toFile="${expectedFile}" />
            </steps>
        </webtest>
    </target>

Run it once to save the expected image then again will compare it.
Swap to the other "testUrl" and it should then fail.

We had to do a few tweaks a few months back to make it work for
PDFs as earlier versions were corrupting the binary input file
under certain circumstances. What version are you using?

Cheers, Paul.

Rob Manthey wrote:
I've not been able to get webtest or groovy to do a diff on a remote image vs a local file. Can anyone suggest a probable way to do this?
I've tried using various combinations of code scraps as follows -
<invoke description="Invoking URL" url="http://localhost:8080/t3000/images/logo.jpg"/> <compareToExpected description="Comparing Images" toFile="../../src/web/images/logo.jpg" />

In groovy I've tried various uses of com.jj.javadiff.Diff java.net.URL sun.awt.image.URLImageSource without luck. I'm thinking that I need to somehow download the binary and save it to a local file using streams/printwriters then run the comparison on the local files, but have not been able to find any good reference mateial on bridging from the URL to the saved image file (ie: not text) ... is there a shorthand groovy way to just download a networked binary file from a url to a local filespec?

Incidentally I have to eventually make it work for png files, not jpgs as the images are dynamic, created by cewolf, and supplied as png ie: url = http://localhost:8080/t3000/cewolf;jsessionid=4EE13F8F6EF6FC4914269138E8B0BB43?img=-314416359&amp;width=570&amp;height=500&amp;iehack=.png

I've managed to scrape the url out of the page, and it "invoke"s ok (as shown in the reports), but I don't think the compare knows to treat it as a binary/png for the JavaDiff ... ?

Any tips/tricks/admonitions ?
Thanks
Rob

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



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



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

Reply via email to