简体   繁体   中英

How can I run cucumber along with selenium and capybara on a machine without a browser?

I am using capybara and selenium to run my cucumber test on my local machine. For the pages that involves javascript, Selenium activates firefox and crawls through the pages in firefox to do the tasks. They cooperates very well on my local machines.

However, in my staging environment, I do not have a GUI browser in it. Is there a way for selenium in a no-browser environment? Or is there any other way to test javascript with cucumber in a no-browser environment?

Yes there is a simple way to run firefox in headless if you're running linux/mac. You can achieve this by using Xvfb standard xwindow utility. There is a gem that wraps it into ruby utility class headless

I've tried several headless browsers - Culerity, Akephalos, Capybara-Webkit for running tests against our (javascript-heavy) application.

All of them resulted in errors that did not occur when the same tests were run in a real browser - so I will second the advice above: your best bet is to get a browser installed and run it in Xvfb.

If there is a way to get Selenium to run headless, I have yet to find it and I spent a long time looking.

You probably want to look at something like Celerity to run headless tests. The drawback however is that you need to use Jruby which isn't that bad at all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM