在 Firefox 中对 selenium Xpath 路径进行原型设计

发布于 2024-08-20 19:05:40 字数 333 浏览 5 评论 0原文

我在测试套件中使用 selenium,但由于设置速度很慢,我想在实时页面上对我的 xpath 进行原型设计,而不是等待测试运行。有没有好的方法可以做到这一点?

  • Firebug 的 $x xpath 似乎工作得不太好
  • jQuery 似乎本身不支持 Xpath 选择器,尽管它在 1.2 版本中曾经支持。
  • 使用本机 javascript 内容 (document.evaluator(...)) 非常冗长,并且不返回列表,使用起来很烦人。

有什么好的解决办法呢?也许有一种方法可以直接使用 selenium 作为一个不错的 REPL?

I'm using selenium in my test suite, but since it's slow to set up, I'd like to prototype my xpaths on live pages, rather than waiting for tests to run. Is there a good way to do this?

  • Firebug's $x xpath seems to not work very well
  • jQuery doesn't seem to support Xpath selectors natively, though it used to in version 1.2.
  • using the native javascript stuff (document.evaluator(...)) is verbose and doesn't return lists, making it irritating to use.

What's a good solution? Perhaps there's a way to use selenium as a nice REPL directly?

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

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

发布评论

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

评论(3

总以为 2024-08-27 19:05:40

下载 Selenium IDE Firefox 插件。它有您正在寻找的东西以及更多。

您可以输入 xpath,它会为您突出显示结果元素。还有下拉菜单可以选择您想要调用的 Selenium 函数。

它还将上下文相关条目添加到上下文菜单中(例如,右键单击某些文本,然后单击“AssertEquals”)。

Download the Selenium IDE Firefox plugin. It has what you're looking for and more.

You can enter an xpath, and it'll highlight the resulting elements for you. There's also drop-downs to select the Selenium functions you want to invoke.

It also adds context sensitive entries to your context menu (right click some text, then "AssertEquals" on it for example.)

一影成城 2024-08-27 19:05:40

使用 Firefox 的 XPather 插件。我总是用它来检查我的 XPath。

还可以考虑使用 TestPlan 来编写测试。它有 Selenium 和 HTMLUnit 作为后端。由于 HTMLUnit 不打开浏览器,因此您的测试运行速度会快得多。一旦 HTMLUnit 一切正常,您就可以在 Selenium 模式下运行并在浏览器中进行相同的测试工作。

http://testplan.brainbrain.net/

Use the XPather add-on for Firefox. I always use it to check out my XPaths.

Also consider using TestPlan to write your tests. It has Selenium and HTMLUnit as a backend. Since HTMLUnit doesn't open a browser your tests run a lot quicker. Once everything is working with HTMLUnit you can just run in Selenium mode and have the same test work in the browser.

http://testplan.brainbrain.net/

黑色毁心梦 2024-08-27 19:05:40

Firefinder 也是一个不错的插件,也许比 firebug 好一点,也许不是。

Firefinder is a nice plugin too, maybe slightly nicer than firebug, maybe not.

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