Cucumber Testing, Counting Page Elements

547 Views Asked by At

I am using cucumber-jvm and writing BDD tests.

I would like to write the step definition for "Then I should see three posts on a page" (The class name is Post)

So my best guess is:

expect(page).to have_css("tbody tr.#{Post}", count: 3)

But that does not work

1

There are 1 best solutions below

0
On

how about:

element = all("tbody tr.#{Post}")
element.count

That should do the trick...