Search |
|||
Felipe Gaucho's blogTesting PDF files with Canoo Webtest and Maven2Posted by felipegaucho on November 18, 2009 at 6:14 AM PST
This week I received one of that lovely and tricky tasks: to learn Canoo webtest, test it and prove its usefulness to the project in three days - convincing the managers that it should be part of the project. The goal of the project is to produce a finance report with ~200 pages and that report should be validated through a zero-errors acceptance test. Several tools were considered, including Selenium and others, but Canoo was choosen due to its PDF test features. Testing PDF documents with Maven & Canoo webtestCanoo webtest can be used in three different ways:
After a first hour of euphoria the things started to get muddy with the configuration of the maven plugin. I am not sure if due to the tight deadline or just because of the scarce documentation on the web, but nevertheless after joining the mailing list of Canoo I started to find my way. Maven configurationThe webtest configurationThe configuration of the test was a bit complicated because I couldn't find a runnable example on the web (the main motivation to this blog entry). After two days translating the ant samples to maven I finally got the below configuration. I believe other enhacements can be done in order to make the whole solution more elegant, but so far it does the job and I have my presentation ready for the managers ;) <project name="Canoo Webtest Sample" basedir="." default="all"> <target name="all"> <ant antfile="checkPageCount.xml" /> <!-- 1 test per PDF page --> <ant antfile="checkWatermark.xml" /> </target> </project> A test example, a simple test to check if the PDF contains a watermark with the word java.net
<project default="test">
<property name="pdf.file" value="${basedir}/foo.pdf" />
<taskdef resource="webtestTaskdefs.properties" />
<target name="test">
<webtest name="watermark">
<config protocol="file" summary="${summary}" saveresponse="false"
resultpath="${resultpath}" resultfile="${resultfile}"
haltonfailure="${haltonfailure}" haltonerror="${haltonerror}"
showhtmlparseroutput="${showhtmlparseroutput}"
autorefresh="${autorefresh}" />
<steps>
<invoke description="get PDF document" url="${pdf.file}" />
<pdfVerifyText description="Check watermark"
text="java.net" startPage="1" endPage="1" />
</steps>
</webtest>
</target>
</project>
Download the complete exampleHere you can download the complete example, it only requires Maven 2 and should work out of the box. any problems trying that, please let me know. In order to run the example, please follow the below steps:
Done, you will find the report in the file AcknowledgmentsI received a helpful support from the Webtest mailing lists, with special thanks to Christoph Lipp, nodje and Marc Guillemot. My task is not yet finished but the support of those community members was fundamental to my first success using Canoo webtest. Blog UPDATE: Canoo published a set of new samples, available here. Take the latest version, unzip and look in the folder »
Comments
Comments are listed in date ascending order (oldest first)
|
CategoriesProgramming
Open Source Community Linux Deployment Business Security Tools J2SE Global Education and Learning JavaOne J2EE Open JDK Java User Groups Java Patterns Netbeans Robotics Mobile and Embedded Web Applications Performance Java Web Services and XML Web Services and XML Patterns Mobility Glassfish Databases Research Blogs Java Enterprise Web Development Tools Java Tools General Testing ArchivesNovember 2009
October 2009 September 2009 August 2009 July 2009 June 2009 May 2009 April 2009 March 2009 January 2009 December 2008 October 2008 September 2008 August 2008 July 2008 June 2008 May 2008 April 2008 March 2008 February 2008 January 2008 December 2007 November 2007 October 2007 September 2007 August 2007 July 2007 June 2007 May 2007 April 2007 March 2007 February 2007 January 2007 December 2006 November 2006 September 2006 August 2006 July 2006 May 2006 March 2006 February 2006 January 2006 December 2005 November 2005 October 2005 Recent Entries |
||
|
|