I currently have a rails app that uses rspec and watir-webdriver for my integration tests. I want to run my integration tests in a headless browser (for speed purposes). Since my development is done on a mac the headless gem won't work for me. I am looking to phantomjs as the solution. Whereas phantomjs works well with rspec/capybara (via poltergeist) and there are plenty of examples on how to make that work, I can't find much in the way of getting it to work well with watir-webdriver and ghostdriver.
I have built the "special" phantomjs that ghostdriver requires but I am lost after that. Has anyone used this setup before (rails/watir-webdriver/ghostdriver)?
My main goal is to speed up my integration tests. So if anyone has a better suggestion than what I have described here, I am flexible :)
Any help is greatly appreciated!
It is now fully supported by Watir-WebDriver and easy to get running:
Steps to get working on OSX
First make sure you have homebrew installed
brew update
brew install phantomjs
Run irb and start using GhostDriver!
require 'watir-webdriver'
b = Watir::Browser.new :phantomjs
b.goto "www.google.com"
b.url #"http://www.google.com.au/"
b.title #"Google"
See full details on this blog post: http://watirmelon.com/2013/02/05/watir-webdriver-with-ghostdriver-on-osx-headless-browser-testing/
Related
I have this code in my controller:
browser = Capybara.current_session
browser.visit url[0]
And it gets error in visit method.
I've installed lib qt5 in my server, i know that i need to use an xserver, but i've installed without changes in the log.
Any suggestions? I think is a server configuration or lib.
PD: in development mode, in my laptop, everything works perfectly, it brokes in production mode.
Thank's guys for giving me clues.
1. Change webkit to poltergeist gem. It have the same result, but better functionality in servers. https://github.com/teampoltergeist/poltergeist
2. Install phantomjs (dependency for poltergeist) by binaries. https://github.com/teampoltergeist/poltergeist#installing-phantomjs
And that's all.
We have a few test cases automated with selenium & capybara during the application development. They all works well when we run it from within the application using rake spec command.
Now in order for the QA team to run these, we don't want to setup the rails environment in their computer. Is there a solution for this?
I am using the following gems,
capybara
selenium
rspec
Any input or suggestion will be really helpful.
Thanks in advance....
I'm looking for the quickest way to run unit tests for a rails app on a Windows machine, preferably automatically. My environment is:
Ruby 1.8.7
Rails 3.0.9
ZenTest 3.6.0 (the latest versions 4.6.2/4.5.0 failed when I tried them for some reason)
Currently they run very slowly, eg. 30s to run a suite of 12 very simple unit tests, time mostly spent starting ruby it seems. The tests themselves take 5s to run according to autotest. For someone used to running 100s of tests in 10s, this is agony, and makes TDD infeasible. I'd even be happy if I could re-run one unit test in less than 5s...
I've searched other questions. Some are old and some conflict. What's the latest accepted wisdom on this? Here are the suggestions I'm aware of:
Use faster_require and/or faster_gem_script (though I had problems getting this working...)
Try JRuby (though that seems as slow starting?)
Upgrade ruby to 1.9.x
spork?
doze?
rails-dev-boost?
Getting a Linux box (or VMware) is out of the question at present, though getting more tempting...
You may want to look at something like spork (and a blog entry).
I write my tests using rspec and I have had great success making my tests run much faster with spork. The reasons tests rails tests run so slowly is because of the amount of time it takes to load rails and all the other gems that you use in your app.
If you can also upgrade to ruby 1.9.2 that would be quite useful.
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?
Setting Capybara.app_host = 'http://localhost:3000' and running script/server -e test in another process worked.
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!
I found this works (in the cucumber env.rb file)
Capybara.default_wait_time = 2000 #default: 2
I want to start contributing to Rails, fixing patches, submitting my own code etc, and the Rails guide states that the tests MUST run. However, they're currently not and I'm not quite sure what to do.
I'm running Mac OS X, Ruby 1.8 and I have all the needed gems installed - what can I do?
The best place to look is the Rails continuous integration server, which will tell you if there are any currently failing tests. It looks like the most recent edge Rails build failed, and if you checked out the code at any time between August 8th and 16th, you probably got a build with a few failures.
The failing CI tests were due to errors with SQLite2 (now removed from master) and Postgres. We fixed these, but none of these run from a normal rake test so your problems probably aren't related.
Make sure you have the latest Mocha gem installed and that you follow the directions provided by Mike Gunderloy on his afreshcup.com blog: http://afreshcup.com/2008/10/27/contributing-to-rails-step-by-step/