We are using Cucumber in our application after we previously used Selenium. Cucumber is far better than Selenium, but it may seem to be complicated since has to write gherkin, step definitions may be page objects.

We are using Celerity with JRuby. The flow is: 'gherkin' calls 'Step definition' calls 'Page objects'.

On one hand, every QA tester writing Cucumber tests will have to be familiar with Ruby in order to use page objects, but on the other hand, we can avoid code duplication and repeatedly broken tests.

What are the pros and cons of using page objects with Cucumber? Should we stop worrying about duplicate code in tests and stick with using step definitions instead of page objects?

  • Please improve your question by focusing on a specific problem or concern you are having. Asking folks if they really use a tool or not is not a real question, it is a poll. See programmers.stackexchange.com/faq#dontask Commented Sep 20, 2011 at 18:04
  • I made an edit to the post along the lines of what @RobertHarvey suggested, but I'm not very familiar with the terminology. I hope someone with more knowledge in this area can correct my wording if necessary.
    – Adam Lear
    Commented Sep 20, 2011 at 18:16
  • 3
    You are discussing Cucumber and Selenium is if they are two different tools to solve the same problem; they aren't. This makes the question confusing, especially because you haven't defined "Page Objects" at all. What API is provided these? Can you provide some code? I'm just not sure what you're asking… Commented Oct 12, 2011 at 19:05
  • As davetron5000 suggests, there is no reason that Selenium (especially selenium RC with the ruby client) cannot be used to define the cucumber steps. I think you should take a closer look at selenium rc, and cucumber step definitions. Commented Nov 4, 2011 at 23:36

1 Answer 1


Actually, cucumber has nothing to do with "pages". The page object itself comes with capybara. In case you intend to use cucumber + capybara for testing web pages you have to use the page object, so there are no cons. Additionally, you always have to worry about duplication in case of test cases, but it is a completely different issue.

The structure in nutshell: cucumber scenario -> step definition(s) -> capybara pages. In the background capybara will use the appropriate selenium drivers.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.