Available Excel Steps
This is the syntax documentation for the Excel steps.
The Excel Steps allow various tests to be performed on Excel files that may be referenced by your web pages. There are steps which let you verify text content, verify styles used and verify sums as well as a document structure filter which allows you to further manipulate the extracted information.
Simple Usage Example
sampleSimpleUsageExample.xml
<project name="Sample: SimpleExcelTest" basedir="." default="main">
<import file="${webtest.home}/lib/taskdef.xml"/>
<target name="main">
<webtest name="myExcelTest">
<config
host="www.myserver.com"
port="8080"
protocol="http"
basepath="myApp"
saveresponse="true"/>
<steps>
<invoke
description="get overview page"
url="overview.html" />
<invoke
description="get PDF document"
url="publicData.xls"/>
<excelVerifyCellValue cell="B2" text="Report"/>
<excelFindRow col="C" startRow="5"
text="TOTAL" property="totalRow"/>
<storeProperty property="lastRow" value="#{totalRow}-1" eval="true"/>
<repeat counterName="row"
startCount="5" endCount="#{lastRow}">
<excelVerifyCellStyle cell="D#{row}"
border="left,bottom:thin,top:dashed"
borderColor="left:red"/>
<excelVerifyCellStyle cell="E#{row}"
type="formula"/>
<excelVerifyCellValue cell="E#{row}"
text="/SUM\(.*\)/"/>
</repeat>
</steps>
</webtest>
</target>
</project>
<import file="${webtest.home}/lib/taskdef.xml"/>
<target name="main">
<webtest name="myExcelTest">
<config
host="www.myserver.com"
port="8080"
protocol="http"
basepath="myApp"
saveresponse="true"/>
<steps>
<invoke
description="get overview page"
url="overview.html" />
<invoke
description="get PDF document"
url="publicData.xls"/>
<excelVerifyCellValue cell="B2" text="Report"/>
<excelFindRow col="C" startRow="5"
text="TOTAL" property="totalRow"/>
<storeProperty property="lastRow" value="#{totalRow}-1" eval="true"/>
<repeat counterName="row"
startCount="5" endCount="#{lastRow}">
<excelVerifyCellStyle cell="D#{row}"
border="left,bottom:thin,top:dashed"
borderColor="left:red"/>
<excelVerifyCellStyle cell="E#{row}"
type="formula"/>
<excelVerifyCellValue cell="E#{row}"
text="/SUM\(.*\)/"/>
</repeat>
</steps>
</webtest>
</target>
</project>
Additional Setup Information
You have three ways to incorporate the Excel steps into your tests:
- Import all steps approach:
- Simply use <import file="${webtest.home}/lib/taskdef.xml"/> as illustrated in the Samples.
- Specific plugins approach:
- You can explicitly define the base and Excel tasks: <taskdef resource="webtest_base_strict.taskdef" classpathref="webtest.all" loaderref="webtest.loader"/> <taskdef resource="webtest_exceltest_relaxed.taskdef" classpathref="webtest.all" loaderref="webtest.loader"/>
- Antlib approach:
- You can use namespaces as follows: <target xmlns:exceltest="antlib:com.canoo.webtest.plugins.exceltest" name="main"> then simply refer to the steps using the namespace you defined, exceltest in this case, e.g. <exceltest:verifyCellValue cell="A1" text="Test"/> <exceltest:verifyCellFormat cell="B3" borderColor="red"/> Note that the excel prefix is stripped off any tasks starting with excel.