Python是否有类似Capybara/Cucumber的东西? [英] Does Python have anything Like Capybara/Cucumber?

查看:351
本文介绍了Python是否有类似Capybara/Cucumber的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ruby在Selenium之上有一个很棒的抽象层,称为Capybara,您可以使用它进行功能/接受/集成测试.它还有另一个名为Cucumber的库,该库使这一步骤更进一步,并允许您实际用英语编写测试.

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.

这两个库都建立在Selenium之上,并且可以用于对任何主要浏览器进行测试,但是由于它们的抽象层,使用它们编写测试非常容易(至少,就像功能测试一样容易).

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).

我的问题是:Python有这样的东西吗?我发现Pythonista可以使用各种工具进行功能测试,但是...

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

A)分裂:不使用Selenium(并且没有IE驱动程序)

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

-编辑- 看来Spliter现在确实使用Selenium(请参阅下面的答案).

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

B)Alfajor:一年多没有更新;看起来死了

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

C)Selenium(原始):很多人似乎直接在使用Selenium,但是似乎抽象层可以使它更容易使用

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

那么,对于Python来说,有谁知道类似Capybara的东西,或者更好的像Cucumber一样的东西(它不一定实际使用Selenium,但它需要支持所有主要的浏览器)?

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)?

*编辑*

对于那些不熟悉Capybara的人,它基本上只是添加了一个API,因此您可以执行以下操作来代替普通的Selenium API:

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 => 'user@example.com'
    fill_in 'Password', :with => 'password'
  end
  click_link 'Sign in'
end

它由Cucumber使用,让您进一步抽象(几乎是英语):

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 |

我会喜欢Python Cucumber,但即使只是Capybara也会有帮助.

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

推荐答案

您可以使用Cucumber测试Python代码-请参见 Cucumber有关更多信息,请访问github上的Wiki .

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

如果您要使用纯Python解决方案,请查看 Lettuce .我从未使用过它,但是有一个关于它和碎片的相当有用的博客条目

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.

这篇关于Python是否有类似Capybara/Cucumber的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆