将旧项目升级到水豚 [英] Upgrade old project to capybara

查看:74
本文介绍了将旧项目升级到水豚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们现在正在与Ruby,Cucumber和Selenium一起执行集成测试.

现在我们要提高测试质量,因此我们想使用Capybara.

现在,由于需要为此重写所有方法,所以我们认为也许有人已经这样做了,并为Capybara在其中工作的Selenium Webdriver写了一个包装.

例如:

包装程序应替换以下内容:

  driver.navigate_to"/home" 

类似

 访问"/home" 

重点是,我们不想重写我们的所有代码,因为在我看来,功能完全相同,并且为驱动程序编写包装程序应该没有那么困难,它可以自动执行此操作.意思是:navigation_to方法只是调用了一个visit方法,我很高兴.

我必须自己编写还是已经完成?

非常感谢!

解决方案

否,目前没有用于该方法的包装器.

您似乎缺少一个事实,即Capybara本身就是围绕selenium-webdriver的包装器,因此您要使用兼容硒的包装器来围绕硒的包装器.再加上这样一个事实,如果您要做的就是用Capybara命令模拟现有的selenium命令,您将不会从Capybara获得任何收益,所以这毫无意义.听起来您的团队最好不保留现有测试,而是使用Capybara编写所有新测试,并且由于现有测试需要更改/维护,因此需要重写/重写它们以使用Capybara及其内置的等待/重试和更友好的API./p>

We are working right now with Ruby, Cucumber and Selenium to perform our integration tests.

Right now we want to improve the quality of our tests and therefore we want to use Capybara.

Now since all our methods need to be rewritten for that, we thought maybe someone has already done that and wrote a wrapper for the selenium webdriver, where Capybara does the job.

For example:

The wrapper should replace the following:

driver.navigate_to "/home"

to something like

visit "/home"

The point is, we don´t want to rewrite all our code, since the functionality out of my view is quite of the same and it should not be that difficult to write a wrapper for driver, which does this automatically. Means: the navigate_to method just calls a visit method, and I am happy.

Do I have to write this on my own, or was this already done?

Thanks alot!

解决方案

No, there is no existing wrapper for that.

You seem to be missing the fact that Capybara is itself a wrapper around selenium-webdriver, so you are asking for a selenium compatible wrapper around a wrapper around selenium. This coupled with the fact that if all you do is emulate your existing selenium commands with Capybara commands you won't be gaining anything from Capybara, so it's pointless. It sounds like your team would be better off leaving the existing tests as they are, writing all new tests using Capybara, and as existing tests need change/maintenance rewriting them to use Capybara with it's built-in waiting/retrying and friendlier API.

这篇关于将旧项目升级到水豚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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