You could perhaps use some Groovy with Scriptom or perhaps Groovy plus
JExcel if it knows more about HTML-flavoured excel files than POI.
Koorosh Vakhshoori wrote:
Hi guys,
I need your advice. I have a web application which when I click on
submit button generates content which is HTML format but the returned
content type is set to ‘/application/vnd.ms-excel’/. The idea is to have
the browser treat the down loaded content as Excel and forward it to
Excel which would read and display it. The application works as
expected, of course only on Windows or on any platform that have an
Excel compatible application which supports reading HTML format. Now
understand this limitation and we are fine with it. However, when I use
the WebTest Excel steps to validate the generated content, I get the
following error:
Invalid header signature; read 723401728380766730, expected
-2226271756974174256
The stack trace is:
java.io.IOException: Invalid header signature; read 723401728380766730,
expected -2226271756974174256
at
org.apache.poi.poifs.storage.HeaderBlockReader.<init>(HeaderBlockReader.java:88)
at
org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:83)
at
com.canoo.webtest.plugins.exceltest.RetryWithCapsPOIFSFileSystem.<init>(RetryWithCapsPOIFSFileSystem.java:22)
at
com.canoo.webtest.plugins.exceltest.AbstractExcelStep.createWorkbook(AbstractExcelStep.java:60)
at
com.canoo.webtest.plugins.exceltest.AbstractExcelStep.getExcelWorkbook(AbstractExcelStep.java:42)
at
com.canoo.webtest.plugins.exceltest.AbstractExcelSheetStep.getExcelSheet(AbstractExcelSheetStep.java:22)
at
com.canoo.webtest.plugins.exceltest.ExcelCellUtils.getExcelCellAt(ExcelCellUtils.java:23)
at
com.canoo.webtest.plugins.exceltest.AbstractExcelCellStep.getExcelCell(AbstractExcelCellStep.java:70)
at
com.canoo.webtest.plugins.exceltest.AbstractExcelCellStep.getCellValue(AbstractExcelCellStep.java:74)
at
com.canoo.webtest.plugins.exceltest.ExcelStoreCellValue.doExecute(ExcelStoreCellValue.java:48)
at com.canoo.webtest.steps.Step.execute(Step.java:104)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at
com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java:43)
at
com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:31)
at com.canoo.webtest.steps.Step.execute(Step.java:104)
at org.apache.tools.ant.Task.perform(Task.java:364)
at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:164)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
After some investigation, I have identify the source to be *Jakarta
POI*, which WebTest Excel step uses to read the Excel content where it
only expects to see binary Excel format and not HTML. This is how
Jakarta POI works and I am not expecting them to change it, but in the
Web context a browser looks at the content type and passes the control
to the application that is registered to handle such content. In this
case, as I mentioned before it would pass it to Excel where it sees the
HTML content and would parse it as such and displays it in Excel
context. Now could anyone suggestions a way to write my WebTest so it
would test the generated content?
Thanks,
Koorosh
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest