How do I use ruby-debug in Capybara w/ selenium

2019-06-25 12:43发布

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?

3条回答
你好瞎i
2楼-- · 2019-06-25 13:32

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!

查看更多
欢心
3楼-- · 2019-06-25 13:39

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

Capybara.default_wait_time = 2000 #default: 2

查看更多
够拽才男人
4楼-- · 2019-06-25 13:40

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

查看更多
登录 后发表回答