perhaps a silly question...

3 views
Skip to first unread message

bearblu

unread,
Oct 21, 2009, 11:17:01 PM10/21/09
to Cukes
Suppose I use the table feature to load a bunch of users e.g.

| name | last_login | email |
| User1 | 10/01/2009 | us...@example.com |
| User2 | 10/10/2009 | us...@example.com |
| User3 | 09/10/2009 | us...@example.com |

And I have a standard rails index view such as:

Name Last Login email
User1 10/01/2009 us...@example.com Edit Delete
User2 10/10/2009 us...@example.com Edit Delete
User3 09/10/2009 us...@example.com Edit Delete


Can I write a step to edit User2? In other words, can I do the
equivalent of click the second Edit link? I could of course build a
Feature with a single user but I am curious if this can be achieved.

Jonathan Linowes

unread,
Oct 22, 2009, 12:22:21 AM10/22/09
to cu...@googlegroups.com
here's a snippet that looks for a link named 'select', you can adjust
to your own situation
The first picks the n-th row (could obviously be generalized),
the second picks the row based on some content


When /^(?:I )?select the (.+) row of the "(.+)" table$/ do |which,
table|
case which
when 'first'
click_link_within 'table tr td', 'select'
when 'second'
click_link_within 'table tr+tr td', 'select'
else
puts "STEP ERROR: dont know #{which} row"
end
end

When /^(?:I )?select the row of the "(.+)" table containing "(.*)"$/
do |table, text|
selector = "//table//tr//td[contains(.,'#{text}')]//.."
click_link_within selector, 'select'
end
-- jon linowes
parkerhill technology group llc
jona...@parkerhill.com
office: 603-838-2884
tech blog: http://vaporbase.com
personal blog: http://jon.linow.es
twitter: @linojon


bearblu

unread,
Oct 22, 2009, 2:21:19 AM10/22/09
to Cukes
Thanks, this looks to be just what I need. I will try it out right
away.
>      jonat...@parkerhill.com
Reply all
Reply to author
Forward
0 new messages