为什么我应该使用水豚,因为可以直接使用硒本身?

发布于 2024-12-20 17:24:43 字数 66 浏览 8 评论 0原文

据我所知,selenium 本身具有实际模拟网页交互的命令(和 gem),那么使用 capybara 的必要性是什么?

From what I have read, selenium itself has the commands(and gem) to actually mimic web page interactions, so what is the necessity to use capybara?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末骤雨初歇 2024-12-27 17:24:43

使用 capybara 而不是 selenium-webdriver 有以下好处:

  • 它是一个更高级别的 API,这意味着您可以对非 Javascript 页面或静态 HTML 使用相同的 API,或者交换不同的驱动程序,例如 capybara-webkit
  • 它是专门为通过 UI 测试 Web 应用程序,因此它具有断言页面正确性的有用方法
  • 它会自动处理在使用真实浏览器进行测试时可能遇到的许多粘性同步问题
  • 它专为测试机架应用程序而设计,因此它将为您启动和管理后台服务器

Using capybara over selenium-webdriver provides the following benefits:

  • It's a higher level API, which means you can use the same API for non-Javascript pages or static HTML, or swap in a different driver, such as capybara-webkit
  • It's designed specifically for testing a web application through the UI, so it has useful methods for asserting that the page is correct
  • It automatically handles many of the sticky synchronization issues you can run into when testing with a real browser
  • It's designed for testing rack applications, so it will boot and manage background servers for you
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文