将 Selenium-IDE 与丰富的 Javascript 应用程序一起使用?

发布于 2024-10-10 07:46:04 字数 1142 浏览 0 评论 0原文

问题

在我的工作场所,我们正在尝试找到为几乎完全由 javascript 驱动的 Intranet 应用程序创建自动化测试的最佳方法。现在,我们正试图在以下两者之间找到一个良好的权衡:

  • 可重用的应用程序代码和可嵌套的 GUI 组件。
  • 测试团队可以轻松创建的测试
  • 可以记录一次然后自动进行的
  • 测试 对站点进行小幅修饰后不会中断的测试

XPath 表达式(或其他可能的表达式,如 jQuery 选择器)通常是从 Selenium-IDE 生成的不可重复且非常脆弱。相反,让 JS 代码为页面上的每个重要 DOM 元素生成特殊的唯一 ID 值……好吧,这本身就是令人头疼的事情,而且可重用的 GUI 组件和 ID 需要在重新测试时保持一致而变得更加复杂。跑步。

其他人在此类事情上取得过哪些成功?如何对丰富的 JS 接口进行自动化应用程序级测试?

限制

  • 我们正在使用 JavascriptMVC 2.0,希望很快就能使用 3.0,以便我们可以升级到 jQuery 1.4.x。
  • 测试人员大多接受过使用 Selenium IDE 直接记录内容的培训。
  • 测试主管更喜欢在页面上的每个可点击元素上使用页面唯一的 HTML ID...
  • 训练测试人员编写或更改特殊表达式(例如告诉他们哪些 HTML 类名是重要的分支点)是不行的。
  • 我们尝试制作可重用的 JavaScript 组件,但这意味着很少有 GUI 组件可以将自己(或它们包含的内容)视为唯一的。
  • 我们的一些组件已经在其操作中使用 HTML ID 值。我无论如何都想避免这样做,但这使基于 ID 的测试的想法变得复杂。
  • 可以向 Selenium-IDE 安装测试人员使用添加自定义工具(如定位器构建器或新的定位器方法)。
  • 从传统浏览器的角度来看,几乎所有发生的事情都发生在单个“页面加载”中,即使项目已保存

当前想法

我正在考虑一个系统,其中 Selenium-IDE 的自定义定位器构建器(javascript 代码)将与我们的系统进行对话测试人员正在记录的应用程序代码。通过这种方式,我们的应用程序部分负责为任何给定的 DOM 元素生成最灵活的表达式(XPath 或 jQuery)。虽然这可以避免需要对测试人员进行更多培训,但我担心这可能是想太多了。

Problem

At my workplace, we're trying to find the best way to create automated-tests for an almost wholly javascript-driven intranet application. Right now we're stuck trying to find a good tradeoff between:

  • Application code in reusable and nest-able GUI components.
  • Tests which are easily created by the testing team
  • Tests which can be recorded once and then automated
  • Tests which do not break after small cosmetic changes to the site

XPath expressions (or other possible expressions, like jQuery selectors) naively generated from Selenium-IDE are often non-repeatable and very fragile. Conversely, having the JS code generate special unique ID values for every important DOM-element on the page... well, that is its own headache, complicated by re-usable GUI components and IDs needing to be consistent when the test is re-run.

What successes have other people had with this kind of thing? How do you do automated application-level testing of a rich JS interface?

Limitations

  • We are using JavascriptMVC 2.0, hopefully 3.0 soon so that we can upgrade to jQuery 1.4.x.
  • The test-making folks are mostly trained to use Selenium IDE to directly record things.
  • The test leads would prefer a page-unique HTML ID on each clickable element on the page...
  • Training the testers to write or alter special expressions (such as telling them which HTML class-names are important branching points) is a no-go.
  • We try to make re-usable javascript components, but this means very few GUI components can treat themselves (or what they contain) as unique.
  • Some of our components already use HTML ID values in their operation. I'd like to avoid doing this anyway, but it complicates the idea of ID-based testing.
  • It may be possible to add custom facilities (like a locator-builder or new locator method) to the Selenium-IDE installation testers use.
  • Almost everything that goes on occurs within a single "page load" from a conventional browser perspective, even when items are saved

Current thoughts

I'm considering a system where a custom locator-builder (javascript code) for Selenium-IDE will talk with our application code as the tester is recording. In this way, our application becomes partially responsible for generating a mostly-flexible expression (XPath or jQuery) for any given DOM element. While this can avoid requiring more training for testers, I worry it may be over-thinking things.

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

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

发布评论

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

评论(2

成熟稳重的好男人 2024-10-17 07:46:04

录制和回放在大规模测试中不起作用。它可能适用于冒烟测试和小型重复任务。

不要尝试生成唯一的 ID,而是尝试使用基于 CSS 的选择器来解决这个问题。生成唯一的 id 是理想的目标,但我认为这在所有实际情况下都是不可能的。

如果您尝试寻找自定义定位器,最好研究一下 BDD。

Record and Playback will not work in large scale testing. It may work for smoke tests and small repetitive tasks.

Instead of trying to generate unique IDs, try to solve that with CSS based selectors. Generating unique ids is ideal goal but I don't think that is possible in all practical cases.

If you trying to look for custom locators, it is better to look into BDD.

罗罗贝儿 2024-10-17 07:46:04

不能将 css 选择器与 Selenium 一起使用吗?这似乎比使用 XPath 更简单一些。

http://saucelabs. com/blog/index.php/2010/01/selenium-totw-css-selectors-in-selenium-demystified/

Can't you use css selectors with Selenium? That seems a little more straightforward than using XPath.

http://saucelabs.com/blog/index.php/2010/01/selenium-totw-css-selectors-in-selenium-demystified/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文