I used following step-definition with cucumber and webrat and everything worked fine:
Then /^I should see "([^\"]*)" worker in the workerlist/ do |number|
response.should have_selector("td.worker_name", :count=>number)
end
I have moved now to selenium and "somehow" the have_selector doesn't take a :count parameter anymore. I get following error:
ArgumentError: wrong number of arguments (2 for 1)
./features/step_definitions/worker_generation_steps.rb:15:in `have_selector'
Next I tried to use assert_contain, but I couldn't find a regex that checks the exact number. Unfortunately, following step definition passes if the number of "class="worker_name"" is less than the expected number.
Then /^I should see "([^\"]*)" worker in the workerlist/ do |number|
assert_contain (/((.*)(class="worker_name"))#{number}/m)
end
My questions:
1.) How could I check the easiest way that in my example "td.worker_name" appears exactly a number of times?
2.) If there is no way around regex: How could I rewrite the regex above so that it checks the exact number of "class="worker_name""?
Thanks a lot!