Hi Michael,

I wouldn't read the saved page in this case but rather change HtmlUnit's behavior. The easiest way is probably to configure your own subclass of DefaultPageCreator on the WebClient instance. This subclass needs to overwrite createPage to parse "application/msexcel" responses as xml.

Cheers,
Marc.
--
Blog: http://mguillem.wordpress.com

Michael Stephan wrote:
Hello Marc,

actually it is all about the verifyXPath command. When doing the 1st invoke I retrieve an excel/xml file, in the response the html header is set to application/msexcel, therefore the underlying framework of webtest does not covert this into a xml page, it is stored as undefined page. If I would call verifyXPath on this it would fail, since this only supports html or xml. However if I store the response to a file and then read it again with a 2nd invoke directly from the disk the mime header is lost and the file is read as proper xml. Then I can proceed with the verifyXPath command.

Hopefully my explanation is clear.

Regards,
Michael

On Wed, Jun 23, 2010 at 12:15 PM, Marc Guillemot <[email protected] <mailto:[email protected]>> wrote:

    Hi,

    may I ask why you want to work on the file save on the file system
    rather than directly on the DOM?

    Cheers,
    Marc.
-- Blog: http://mguillem.wordpress.com

    Michael Stephan wrote:

        Hi, thanks for your response.

        saveResponse I have turned on, it wrote the result directly to
        the result folder harddrive. Unfortunately the name is not
        easily predictable. Let's image the following scenario.

        webtest1
        command1: invoke -> write to local (writes to
        result/001/001_invoke ...)
        command2: invoke -> read from local

        If there would be another webtest before webtest1 the directory
        names would be different, the same is if there are other command
        before command1. I tried to set the savePrefix explicitely which
        is the path relative to the result folder nevertheless this does
        not really solve the problem. The nicest would be a function to
        retrieve the location of the last saved http call.

        Regards,
        Michael


        On Tue, Jun 22, 2010 at 12:59 PM, Thomas Klein
        <[email protected] <mailto:[email protected]>
        <mailto:[email protected] <mailto:[email protected]>>> wrote:

           Hi, perhaps this helps - from the manual, for the "invoke" step:
                The result of the request is internally stored and its
        contents can
           be verified with one or more /<verify...>/ steps. If the
           /saveresponse/ option in the config
           <http://webtest.canoo.com/webtest/manual/config.html> element is
           enabled, the result (HTML
           <http://webtest.canoo.com/webtest/manual/annotatedRefs.html#HTML>

           source) will be written to a file for later viewing.
                Also check the "saveResponse" option (below). However, I
        think
           storing the result of "invoke" in the results subfolder of your
           webtest project is the normal behaviour of webtest. The file
        should
           already be there - just give it a try once you ran your "invoke"
           step. It should be called something similar to the step name...
                *saveResponse*
               Required? no         Whether to make a permanent copy of
        received responses.
               Overrides the default value set in         the <config>
        element.
                Once you have finished your scripted processing of the
        Excel file, a
           separate "invoke" on the processed file should provide you
        with what
           you wanted to get... let us know if that helped.
                HTH
           Thomas
*Thomas Klein*
           Senior Associate, QA |* SapientNitro*

------------------------------------------------------------------------
           *From:* [email protected]
        <mailto:[email protected]>
           <mailto:[email protected]
        <mailto:[email protected]>>

           [[email protected]
        <mailto:[email protected]>
           <mailto:[email protected]
        <mailto:[email protected]>>] On Behalf Of Michael
        Stephan
           [[email protected] <mailto:[email protected]>
        <mailto:[email protected] <mailto:[email protected]>>]

           *Sent:* Tuesday, June 22, 2010 11:27
           *To:* [email protected]
        <mailto:[email protected]> <mailto:[email protected]
        <mailto:[email protected]>>

           *Subject:* [Webtest] invoke stores response to harddisk, how
        to get
           path to locally stored response in following groovy step

           Dear all,

           I have the following problem. I'm triggering two commands,
        the first
           is a simple invoke, the second is some groovy code. In the groovy
           code I would need to access the response which was stored to the
           file in the invoke step.

           1) <invoke .....>: stores the response (which is an excel file,
           resulting in an UnexpectedPage) to a local file

           2) <groovy .....>: how to get the path to the locally stored
        response

           I already tried to access the filename with
           step.context.currentResponseFile but this is set to NULL.
        Maybe you
           could help me finding a solution.


           Thanks,
           Michael




    _______________________________________________
    WebTest mailing list
    [email protected] <mailto:[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