Paul, 
Thank you so much for the explanation, this will truly help.  The site for 
groovy (groovy.codehaus.org) seems to be down, do you have some documentation 
you could fwd me for syntax, examples etc.. for groovy?   Also, when I enter 
into a scriptstep what objects/variables do I have access to?
 
-Brian
 
 
-----Original Message----- 
From: [EMAIL PROTECTED] on behalf of Paul King 
Sent: Sat 5/20/2006 8:36 AM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: Re: [Webtest] filters




        Hi Brian, I would probably use some scripting (e.g. Groovy)
        to do what you are after. You can optionally use filters
        to select just a minimal part of your page - this may simplify
        the scripting code slightly. Invoke your first page, do the
        scripting and store the server names into a list. Invoke the
        second page, do the scripting and store into a list. Then
        compare the two lists.
        
        If you use the Groovy step, the lists will stay in the binding
        across your Groovy steps (since build 1276). If you are using
        scriptStep, then you will need to have the attribute keep="true"
        to have the binding carry over.
        
        Your script code could look something like:
        
            <steps>
                <invoke url="${testUrl}"/>
                <selectLinesFilter startRegex=".*Servers Added.*" 
includeStart="no"
                    stopRegex=".*Servers Modified.*" includeStop="no"/>
                <scriptStep language="groovy"><![CDATA[
                    servers = [ ]
                    root = new XmlSlurper().parseText(document.asXml())
                    root.depthFirst().findAll{ node ->
                        node.text().contains('Server') }.each{ lines ->
                            lines.toString().split('\n').findAll{ str ->
                                str.trim().size() > 0}.each{ servers << 
it.trim() }}
                    assert servers.unique().size() == 3
                ]]></scriptStep>
            </steps>
        
        This was run on the following HTML:
        
        <html>
        <body>
        <h1>A Heading to ignore</h1>
        <p>Servers Added:</p><br/>
        Server1<br/>
        Server2<br/>
        Server3<br/>
        <p>Servers Modified</p>
        </body>
        </html>
        
        If your text is a little more structured you will be able to shorten
        the script quite a lot.
        
        Cheers, Paul.
        
        Brian Spindler wrote:
        > Guys/Gals,
        >
        > I've been looking at the filter steps and believe they are what I 
need however I am having a hard time finding all the logic I need so I hoped 
someone could quickly point me in the right direction.  This is a simplified 
example of the HTML that I might want to filter:
        >
        > <p> Servers Added:</p><br/>
        > Server1<br/>
        > Server2<br/>
        > Server3<br/>
        > <p> Servers Modified</p>
        >
        > I was using a selectLinesFilter to try and capture the 
"Server1<br/>Server2<br/>Server3<br/>" however what I am trying to accomplish 
is to extract the servers and compare them to the results of another HTML page. 
 The reason I think this is going to get difficult is because the other page 
the server names will be within <td></td> tags.  Does this mean I need to 
extract the server names individually to where I confirm there existence one by 
one with verifyText steps?
        >
        > Any help would be greatly appreciated.
        >
        > Thanks!
        > -Brian
        
        _______________________________________________
        WebTest mailing list
        [email protected]
        http://lists.canoo.com/mailman/listinfo/webtest
        

Reply via email to