How to generate results after selenium test in Ruby? - ruby-on-rails

I have recently started using ruby to write tests for selenium but I would like a way for the tests to be exported into a results file.
For an example of what i mean. I was exporting the tests from the IDE to html and then running them using
java -jar selenium-server-standalone-2.39.0.jar -htmlSuite *firefox http://google.com /path/to/suite.html /path/to/results.html
in the command line and it would run the suite.html and then post the results in results.html
Is this possible in Ruby?

Looks like someone has already taken on the same challenge before. See this article how to export results when running selenium ruby webdriver scripts to output files from command prompt ruby window.
You may have to write up a rake file, but I believe it will be a good experience that will make you better acquainted with ruby and how to go about selenium testing with it.

Related

Is there a way to get JUnit code coverage when running in the browser?

We are currently working on getting better code coverage for one of our JS libraries. I have the The Intern up and running, and can run tests in the browser. However, our libraries create DOM elements in some of their functions, making it so we can't run JUnit from the terminal because Node.js doesn't allow for DOM construction in tests. Is there a way we can get JUnit code coverage on the html and console output we get when we run The Intern in the browser?
I found the answer. From this link: https://theintern.github.io/intern/#local-selenium
Using ChromeDriver (Chrome-only)
If you’re just looking to have a local environment for developing functional tests, a stand-alone ChromeDriver installation works great.
1. Download the latest version of ChromeDriver
2. Set tunnel to 'NullTunnel'
3. Run chromedriver --port=4444 --url-base=wd/hub
4. Set your environments capabilities to [ { browserName: 'chrome' } ]
5. Run the test runner
Once you have that setup and running, you can run
node_modules/intern/bin/intern-runner.js config=tests/intern reporters=JUnit filename=junit.xml
This will allow the tests to run in a chrome instance, and then output the results to a report that can then be upload somewhere.

Print feature file names while running all the cucumber features

When I run all my cucumber features my system hangs, there seems to be a memory leak. I would like to find out which features create this problem. There are lot of feature files so I cannot run them individually
Using the pretty formatter will print the feature and scenario names as the tests run
cucumber --format pretty
You can also add this to the cucumber.yml config file if you are using rake to run the cukes.

Running phantomjs from a Ruby on Rails application

I'm interested in using Phantomjs and I'd like to run it from my Ruby on Rails application. However, this is a command line tool (i.e. I'd need to run something like phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png in my terminal). How would I execute a command line tool from my app?
Use backticks in your ruby code e.g.:
output = `phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png`

db:migrate fails in Emacs shell

When I rake my db in emacs, it fails– although it works fine in terminal. The error is related specifically to an environment variable that emacs doesn't seem to be picking up on. What is the best way to resolve this in .emacs? Do I need to source my profile every time I start emacs?
Which emacs shell are you using? There are a few different types which are good for different cases. I recently read this article which you may find informative: http://www.masteringemacs.org/articles/2010/11/01/running-shells-in-emacs-overview/
I suggest trying simply M-x shell which will simply run your default shell in emacs (usually bash).

Using Rails commands with a disabled command line

I'm using a public Windows computer where the command line has been disabled. By using Instant Rails I'm able to create customize and test rails apps to some degree but can't use the Rails commands.
Question:
How do I use these commands with a disabled command line?
I've tried using SciTe, Notepad++ but all these just access the same disabled cmd so those won't work.
Some editors that deal with Rails specifically can do this. Netbeans, RadRails and RubyMine come to mind.
However, if your command line is disabled, you're probably not going to be able to `install them either.
As EmFi said, NetBeans has both a built-in Rails console and the ability to run migrations and Rake tasks from a menu. So with NetBeans, you'd be able to run migration and Rake tasks without needing a command line at all.
Here's another option...
If you're able to install software on the machine, maybe you could install something like Cygwin or MinGW. They provide a command prompt with a Unix-like environment. I've used both. Personally, I think MinGW would give you a smoother, simpler experience with fewer gotchas, but Cygwin is very popular.

Resources