Capybara+RSpec:它可以用于任何网络应用程序吗?
我在 http://railscasts.com/episodes/257-request- 看到了railscast specs-and-capybara 描述了如何在 Rails 应用程序上将 Capybara 与 RSpec 结合使用。
是否可以使用 Capybara/Selenium 来测试您无权访问代码的 Web 应用程序,或者它不是 Ruby/Rack 应用程序。换句话说,是否可以使用 Capybara/Selenium 对 Web 应用程序进行黑盒测试?如果是这样,怎么办?
我问这个问题是因为所有代码示例都暗示存在 Ruby 或 Rails 代码库。
I saw the railscast at http://railscasts.com/episodes/257-request-specs-and-capybara which describes how to use Capybara with RSpec on a Rails application.
Is it possible to use Capybara/Selenium to test a web application over which you have no access to the code, or it is not a Ruby/Rack application. Worded another way, is it possible to black-box test a web app using Capybara/Selenium? If so, how?
I ask because all of the code samples imply the existence of a Ruby or Rails code base.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我看不出有什么理由说这是不可能的。假设您的 Web 应用程序可以通过 HTTP 访问,那么应该没问题(这显然很可能是真的)。
所有 RSpec 请求规范基本上都是黑盒测试。这就是请求规范的要点 - 您想要模拟真实用户并练习整个应用程序堆栈 - 从 HTML 视图开始一直到数据库访问。黄瓜的特征也是如此。
编写规范可能不太舒服,因为您不能依赖 Web 应用程序来遵守 Rails 约定。
无论如何...我希望这有帮助。
I don't see any reason why that wouldn't be possible. Assuming your Web Application is accessible via HTTP, you should be fine (this is obviously VERY likely to be true).
All RSpec Request Specs are basically black box tests. That's the point of Request Specs - you want to simulate a real user and exercise your whole Application stack - starting with HTML views down to database access. The same is true for cucumber features.
Writing you Specs might be a little less comfortable, because you can't rely on the Web Application to adhere to Rails conventions.
Anyway... I hope this helps.
当然,事实上,最常见的初始测试是自动化 www.google.com。事实证明,这是一个糟糕的第一次尝试(现代的 Google 非常 AJAXy 且微妙),但这是每个人首先想到的。紧随其后的是 GMail,更是如此。 :-)
Sure, in fact, the most common initial test is to automate www.google.com. It turns out to be a bad first attempt (the modern Google is very AJAXy and subtle), but it's what everybody thinks of first. Followed quickly by GMail, which is even moreso. :-)
是的。
您只需要使用“访问”功能即可直接转到您要测试的 URL。
然后,您可以使用 capybara 函数找到任何 HTML 元素
Yes.
You just need to use a "visit" function which goes directly to the URL you want to test.
Then, you can find any of the HTML elements using capybara functions