Does Python have anything Like Capybara/Cucumber?

machineghost picture machineghost · Feb 28, 2012 · Viewed 34.3k times · Source

Ruby has this great abstraction layer on top of Selenium called Capybara, which you can use do functional/acceptance/integration testing. It also has another library called Cucumber which takes this a step further and lets you actually write tests in English.

Both libraries are built on top of Selenium, and can be used to test against any major browser, but because of their abstraction layers it's super easy to write tests using them (well, as easy as functional testing gets at least).

My question is: does Python have anything like that? I have found Pythonistas doing functional testing with various tools but ...

A) Splinter: doesn't use Selenium (and doesn't have an IE driver)

-EDIT- It appears Spliter now does use Selenium (see answers below).

B) Alfajor: hasn't been updated in over a year; looks dead

C) Selenium (raw): a lot of people seem to be using Selenium directly, but it seems like an abstraction layer could make it a lot easier to use

So, does anyone know of anything Capybara-like, or better yet Cucumber-like, for Python (it doesn't have to actually use Selenium, but it needs to support all major browsers)?

* EDIT *

For those that aren't familiar with Capybara, it basically just adds an API so that instead of the normal Selenium API you can do something like this:

When /I sign in/ do
  within("#session") do
    fill_in 'Login', :with => '[email protected]'
    fill_in 'Password', :with => 'password'
  end
  click_link 'Sign in'
end

It's used by Cucumber, which let's you further abstract (almost to English):

Scenario Outline: Add two numbers
Given I have entered <input_1> into the calculator
And I have entered <input_2> into the calculator
When I press <button>
Then the result should be <output> on the screen

Examples:
| input_1 | input_2 | button | output |
| 20 | 30 | add | 50 |

I would LOVE a Python Cucumber equivalent, but even just a Capybara equivalent would be helpful.

Answer

D_Bye picture D_Bye · Mar 1, 2012

You can test Python code using Cucumber - see the Cucumber wiki on github for more information.

If you want a pure Python solution, check out Lettuce. I've never used it, but there is a fairly useful looking blog entry about it and splinter here.