Testing the cell value of a html table with Geb/Spock

604 views
Skip to first unread message

Ian M

unread,
Mar 14, 2011, 9:53:49 AM3/14/11
to Spock Framework - User
Hi,

Say you have a html data table headed by years across the top, and
each row with a td, with the month name in the 1st column has anyone
managed to come up with a generic means of testing that accessing with
the value via some generic parametrized function/test.

i.e. we really want to get the value (tableID=myReport,column=2008,
row=Mar)

| |2007|2008|
|Jan|943|645|
|Feb|234|187|
|Mar|129|165|
|April|103|671|

Test from Spec:
myReport_March_2008_Value.text()=="€2,307"

Page defintion:
myReport_March_2008_10Value{ $("#myReport table tbody tr:nth-child(2)
td:nth-child(2)") }

Disadvantage of the page definition is that if the table gains/looses
columns - years in this case, then the test will fail due for reason
not due to the application code. I guess that's what some would call a
brittle test? Either way, I think it would be easier to specificy
table cell evalutors with a col,row heading rather than an integer.
This would hopefully make it easier to write, and then more people
will write tests :)

Would be great to get your thoughts.

Cheers,

Ian.

p.s. Sorry for any confusion over which element of Spock/Geb etc I'm
referring to here - I'm new! :)




Luke Daley

unread,
Mar 14, 2011, 7:51:26 PM3/14/11
to spockfr...@googlegroups.com
Hi Ian,

I have replied over on the Geb list.

This question is specific to Geb and not related to Spock.

> --
> You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
> To post to this group, send email to spockfr...@googlegroups.com.
> To unsubscribe from this group, send email to spockframewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.
>

Reply all
Reply to author
Forward
0 new messages