Hi Michael,

what about writing your own step for such a verification? It will make
your code far more readable and you won't be limited by XPath possibilities:

<groovy>
import com.canoo.webtest.steps.Step

class MyTableVerification extends Step
{
  String xpath

  void doExecute()
  {
        def table = context.currentResponse.getFirstByXPath(xpath)
        ... // your verifications here
  }

}
project.addTaskDefinition("myTableVerification", MyTableVerification)
</groovy>

Usage:

<myTableVerification xpath="//path/to/your/table"/>

Cheers,
Marc.
-- 
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com

Michael Zwick wrote:
> I think, the sum()-function can only by applied to node assemblies. With 
> XPath 1.0 it can probably not be done in one statement, but only recursively 
> (with XPath 2.0 it is possible, however, since there are loops and return 
> statements). This in turn implies the question about the supported XPath 
> standard...
> 
> Michael
> 
> 
> -----Original Message-----
> From: webtest-ad...@lists.canoo.com [mailto:webtest-ad...@lists.canoo.com] On 
> Behalf Of Michael Zwick
> Sent: Mittwoch, 25. Februar 2009 16:25
> To: webtest@lists.canoo.com
> Subject: [Webtest] RE: table consistency check
> 
> Maybe just a question on XPath:
> 
> Can anybody give me a hint how to get the multiplication results of the 
> values of two attributes (@colspan, @rowspan) from all 'td' nodes (that have 
> the two attributes) and summing them up. In principal something like this 
> (which doesn't work...):
> 
> Sum(//t...@colspan and @rowspan]/@colsp...@rowspan)
> 
> Or is it not possible with one statement?
> 
> Thanks!
> Michael
> 
> 
> -----Original Message-----
> From: webtest-ad...@lists.canoo.com [mailto:webtest-ad...@lists.canoo.com] On 
> Behalf Of Michael Zwick
> Sent: Dienstag, 24. Februar 2009 15:47
> To: webtest@lists.canoo.com
> Subject: [Webtest] table consistency check
> 
> Hi,
> 
> I'm currently setting up a test case for checking the consistency of tables 
> in my HTML documents. The tables in my app are generated dynamically 
> depending on query strings and data in an underlying DB. As it happens, but 
> should not happen ;-), sometimes cells are omitted and missing in the table. 
> Hence I'd like to check if the table's border is rectangular.
> 
> --> I wonder, if there is anyone also checking his/her tables for consistency 
> in the sense I described or similarly. I'd be interested to hear how the 
> problem was tackled.
> 
> What I'm doing for a given table is (using XPath):
> 0. Get the XPath of the table to be tested according to some string contained,
> 1. Determine the number of columns of the header line for this table,
> 2. Determine the number of the columns in the line below the header line for 
> this table (and comparing it to 1.),
> 3. Determine the number of total lines of this table,
> 4. Determine the total number of cells of the table (which allows me to do 
> more consistency checks: Total number divided by number of lines =? number of 
> columns)
> 
> BTW, the XPath get quite lengthy because of @col-/@rowspan... But it seems to 
> be possible.
> 
> --> With 4. I have this problem:
> Within the formula I need to sum up the multiplied values of @colspan and 
> @rowspan for nodes having these attributes. I.e. I'd like to do something 
> like this:
> sum(table[1]/tbody/tr/t...@colspan and @rowspan]/@colsp...@rowspan)
> But this doesn't work: That way I can select one of the two attributes only.
> 
> I would very much appreciate if somebody (maybe more familiar with XPath than 
> me...) could give me a hint how to do it correctly.
> 
> Thanks a lot, Cheers
> Michael
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
> 

_______________________________________________
WebTest mailing list
WebTest@lists.canoo.com
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to