如何在 Capybara 中使用 ruby​​-debug 和 selenium

发布于 2024-10-17 18:20:54 字数 557 浏览 2 评论 0原文

我们让 Capybara 使用 selenium 驱动程序,但是当我尝试在步骤中使用“调试器”时,它不太工作。

例如,在调试控制台中输入“page”有效,但输入“page.body”会挂起。

当尝试将调试器与 akephalos 驱动程序一起使用时,我们也遇到了奇怪的情况。使用 akephalos,我们无法输入调试提示符...实际上我们可以,但是您必须按几次键才能在终端中随机显示一个字母。执行“Ctrl-C”让我们输入,但我们收到了诸如“DRb 连接...某事”之类的错误(抱歉,不再有确切的错误)。

我认为问题在于像 selenium 和 akephalos 这样的驱动程序在同一进程中运行测试和服务器,这会混淆 ruby​​-debug。我将尝试单独运行服务器(脚本/服务器测试)并使用 Capybara.app_host = 'http://localhost:3000' 看看这是否会产生影响。我用 akephalos 尝试过,但没有取得任何进展,因为它只是启动了另一个进程内服务器。

有没有人使用 ruby​​-debug 与 Capybara 和 selenium 一起使用?这对其他人有用吗?我错过了一些明显的东西吗?

We have Capybara working with the selenium driver but when I try to use 'debugger' inside a step it doesn't quite work.

e.g. in the debug console entering 'page' works but entering 'page.body' hangs.

We also had weirdness when trying to use debugger with the akephalos driver. With akephalos we couldn't type in the debug prompt... well actually we could but you had to hit the key several times before a letter would randomly show up in the terminal. Doing a 'Ctrl-C' let us type but we got errors like 'DRb connection ...something' (sorry don't have the exact error anymore).

I think the problem is that drivers like selenium and akephalos run the tests and a server in the same process and it confuses ruby-debug. I'm going to try running the server separately (script/server test) and use Capybara.app_host = 'http://localhost:3000' to see if that will make a difference. I tried that with akephalos but didn't get anywhere since it just launched another in-process server anyway.

Is there anyone out there using ruby-debug with Capybara and selenium? Is this working for anyone else? Am I missing something obvious?

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

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

发布评论

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

评论(3

年华零落成诗 2024-10-24 18:20:54

设置 Capybara.app_host = 'http://localhost:3000' 并在另一个进程中运行 script/server -e test 有效。

Setting Capybara.app_host = 'http://localhost:3000' and running script/server -e test in another process worked.

〃温暖了心ぐ 2024-10-24 18:20:54

我自己没有真正的答案,但你的问题让我想起了这篇文章:

Selenium 不适用于 Cucumber /Capybara(开箱即用)- MacOSX

提问者展示了他如何使用 ruby​​-debug 来找出为什么缺少的依赖项会帮助 selenium 无法打开浏览器。

希望这有帮助!

I don't have a real answer myself, but your question reminded me of this post:

Selenium doesn't work with Cucumber/Capybara (out of the box) - MacOSX

Where the questioner shows how he used ruby-debug to figure out why a missing dependency was helping selenium fail to open the browser.

Hope this helps!

萌面超妹 2024-10-24 18:20:54

我发现这个有效(在黄瓜 env.rb 文件中)

Capybara.default_wait_time = 2000 #default: 2

I found this works (in the cucumber env.rb file)

Capybara.default_wait_time = 2000 #default: 2

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