Title: How to test rails javascript and ajax without a browser
Tags: javascript;ruby-on-rails;ajax;testing;capybara
Question: When i use RSpec with Capybara to test my rails javascript page, I get the following error:
Selenium75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0WebDriver75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0rror75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0WebDriverError:        Could not find Firefox binary (os=linux).
Actually my rails scripts are all written on the linux server, where there is on brower installed, and desktop software is not supported on the server (since X11 is not installed).
How can I test javascript in this situation. Or is there a brower that works without X11 installed like wget? Thanks.


Here is another answer: What you want is the capybara-webkit gem, which will allow you to run your browser tests in "headless" mode, i.e. without an actual browser being open. You'll need to install QT (a cross-platform development toolkit) to get it to work, because it uses the QT webkit. See the documentation for details on installing on different OSs.
I use this setup for my js-dependent tests and it works like a charm.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:09/18/12', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><ruby-on-rails><ajax><testing><capybara>', 'Title': 'How to test rails javascript and ajax without a browser', 'ViewCount': 548, 'id': 12469613, 'user_AboutMe': '', 'user_AccountId': 1852894.0, 'user_DisplayName': 'tommy', 'user_Reputation': 31.0, 'user_Views': 3.0, 'user_id': 1679052.0}}