[Webtest] pdftests using invoke

etienne studer webtest@lists.canoo.com
Fri, 9 Apr 2004 00:07:58 +0200

Hi Lisa

See the selftest
which is pretty much your use case. Right?

When webtest stores a response in a file, it gives the file an extension
which is based on the response mime type.

for mime type details.

Do you set the response mime type to "application/pdf" in the response which
contains the PDF document? If so, then webtest will store the response in a
file with a name that ends with .pdf - which is what you want.

Can you find the generated PDF file with a .pdf extension in your specified
resultpath? Otherwise, the next webtest step in which you check the PDF
document title will throw the exception you posted in your previous mail.

I hope that helps.

Best regards, Etienne

-----Original Message-----
From: webtest-admin@lists.canoo.com
[mailto:webtest-admin@lists.canoo.com]On Behalf Of lisa.crispin@att.net
Sent: Donnerstag, 8. April 2004 18:26
To: etienne studer
Cc: webtest@lists.canoo.com
Subject: RE: [Webtest] pdftests using invoke

Hi Etienne,
The link dynamically creates a PDF file which is brought up in Acrobat
reader.  It doesn't get a .pdf extension unless the user saves it.  I would
assume this is not an uncommon way to display PDF files on a website?  Is
there no way for Canoo to test this?  It did used to work, before the PDF
support was added to Canoo, I'm not clear on why it blows up now if I
clicklink on a link that generates a PDF file.

> Hi Lisa
> Have a look at your stacktrace below:
> Exception raised: com.canoo.webtest.engine.StepExecutionException: File
> not have extension '.pdf''
> Obviously, the document returned is not a pdf document. Or at least it
> not have the .pdf extension.
> I hope this helps for further debugging.
> Best regards, Etienne
> -----Original Message-----
> From: lisa.crispin@att.net [mailto:lisa.crispin@att.net]
> Sent: Donnerstag, 8. April 2004 02:31
> To: webtest@lists.canoo.com
> Cc: etienne studer; Webtest
> Subject: Re: [Webtest] pdftests using invoke
> Hi Etienne,
> I had originally had my scripts as you say, using clicklink to click on
> link to the PDF file.  At that time, there was no pdf support in WebTest
> all I could do was <previousresponse> and go back.  It was useful in that
> would fail if the PDF file was missing.
> After installing a build that had the PDF support, the clicklinks on the
> links to PDF files stopped working.  I noticed all the examples in the
> "Available Extension Steps" doc have invoke rather than clicklink, so I
> invoke, but wasn't happy that I couldn't use clicklink.  Just now I tried
> clicklink as you suggested, with the latest build (432).  I still get an
> error trying to use clicklink. I do have an invoke at the start of the
> then there are man Here's my test:
> 	<invoke stepid="go to step 4"
>                	url="control.jsp?site=erStart&amp;page=step4"/>
> 	<clicklink stepid="Click program agreement"
> 		label="Program Agreement"/>
> Here's the relevant HTML:
> <li class="body"><a class="bodyLink" target="_blank"
> href="/pdfsend?type=4103&ts=46297">Program Agreement</a></li>
> Here is the error:
> file:c:/canoo/SmokeTest/PlanEstTourTest.xml:21: Test failed.
> Exception raised: com.canoo.webtest.engine.StepExecutionException: File
> not
>  have extension '.pdf''), Step: VerifyPdfDocumentTitleStep at
> file:../modules/pl
> anDocs.xml:10:  with (title="Program Agreement", stepId="verify program
> agreemen
> t",
> stepType="verifyPdfTitle")com.canoo.webtest.engine.StepExecutionException:
> ile does not have extension '.pdf''), Step: VerifyPdfDocumentTitleStep at
> file:.
> ./modules/planDocs.xml:10:  with (title="Program Agreement",
> prog
> ram agreement", stepType="verifyPdfTitle")
>         at
> com.canoo.webtest.steps.pdftest.AbstractVerifyPdfStep.verifyLastRespo
> nseFileNameAvailable(AbstractVerifyPdfStep.java:89)
>         at
> com.canoo.webtest.steps.pdftest.AbstractVerifyPdfStep.doExecute(Abstr
> actVerifyPdfStep.java:73)
>         at com.canoo.webtest.steps.Step.execute(Step.java:99)
>         at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:26)
>         at
> com.canoo.webtest.ant.TestSpecificationTask.execute(TestSpecification
> Task.java:68)
>         at org.apache.tools.ant.Task.perform(Task.java:341)
>         at org.apache.tools.ant.Target.execute(Target.java:309)
>         at org.apache.tools.ant.Target.performTasks(Target.java:336)
>         at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
>         at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
>         at org.apache.tools.ant.Main.runBuild(Main.java:609)
>         at org.apache.tools.ant.Main.start(Main.java:196)
>         at org.apache.tools.ant.Main.main(Main.java:235)
> It works if I do this instead, but then, I am only able to check the
> contents of the PDF file, I'm not able to know for sure that clicking on
> this link gets me the correct PDF file.  I'm not sure why this worked in a
> build of WebTest that predated the PDF support, but doesn't work now.
> 	<invoke stepid="get program agreement document"
>                	url="pdfsend?type=4103"/>
> What may I do in my test to be able to see that clicking on a particular
> link that should bring up a PDF file, actually does?
> thank you very much,
> Lisa
> > Hi Lisa
> >
> > Testing PDF documents works with invoke as well as with clicklink.
> > See example below using clicklink.
> >
> > Best regards, Etienne
> >
> >
> > <invoke
> >   stepid="Go to overview page"
> >   url="index.html"/>
> > <clicklink
> >   label="PDF Doku A"/>
> > <verifyPdfTitle
> >   title="TestDokuA"/>
> > <previousresponse stepid="Go back to overview page"/>
> > <clicklink
> >   label="PDF Doku B"/>
> > <decryptPdfDocument
> >   password="mymaster"/>
> > <verifyPdfTitle
> >   title="TestDokuB"/>
> >
> >
> >
> > Hello,
> > The new PDF support is really swell!  We're making good use of it.
> > you for providing this immensely useful functionality!
> >
> > I have a question which I hope isn't too dumb.  Before the PDF support
> > introduced, I just did a clicklink on the link to get the PDF, I
> > check it so I just used previousresponse to go back, but I could see the
> > documents in the result folder.
> >
> > So I was doing something like this:
> > 	 <clicklink stepid="Click adoption agreement"
> > 		label="Plan Adoption Agreement"/>
> >
> > Now, I use the invoke to get the PDF doc via the URL, which works fine.
> The
> > clicklink doesn't appear to bring up the correct PDF anymore.  If I have
> one
> > invoke in my test, the clicklink will just keep bringing up the same PDF
> > file as invoked via the URL, no matter what link it's clicking on.  If I
> > don't have any invoke for the PDF URL, I don't get errors but it doesn't
> > save the PDF docs at all, so I imagine it isn't even bringing them up.
> > fact, my server sends me the same sort of errors I would get if I
> a
> > link in a real session and then hit the stop button on the PDF popup
> without
> > letting it finish rendering.
> >
> > So the dumb part of this question is, by invoking the PDF via the URL,
> > can I be sure that when a user clicks on the link on the page to get to
> the
> > URL, they will get the correct PDF document?  Is there any way to do
> > via the clicklink instead of the invoke?
> >
> > Many thanks,
> > Lisa
> >
> > _______________________________________________
> > WebTest mailing list
> > WebTest@lists.canoo.com
> > http://lists.canoo.com/mailman/listinfo/webtest
WebTest mailing list