开发者

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

开发者 https://www.devze.com 2023-03-22 23:17 出处:网络
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

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 wel开发者_StackOverflowl 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.


There is HTMLUnitDriver which is completly headless - http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.html


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消