Selenium RC - Ruby - Doubt in test report generation and server start/stop option

18 views
Skip to first unread message

Shino

unread,
Feb 3, 2009, 2:33:46 AM2/3/09
to selenium-ruby
I have 2 doubts while working with selenium RC and Ruby. Could anyone
please help me.

1. I recorded some test using selenium IDE
2. Exported the test with option "Ruby - Selenium RC".
3. Installed Ruby
4. Installed selenium client (gem install selenium-client)
5. I downloaded and set up Selenium RC in my machine.
6. I started selenium server from command prompt (-jar selenium-
server.jar)
7. Now able to run the ruby scripts(rb file).

Question 1: There is no test result/report generated after test run.
Could anyone let me know how we can generate test result when we work
with Selenium RC using ruby script ? Will Test Runner work with
Selenium RC and Ruby combination? If so how?

Question 2: Is it possible to start selenium server from the ruby file
which I am running? I mean, when I try to run my script, it should
automatically start selenium server and at the end of test it should
stop the server. Is there any way to do this from ruby file?

Appreciate if anyone could help me in this...

ph7

unread,
Feb 3, 2009, 11:36:00 AM2/3/09
to selenium-ruby
Hi Shinoj,

On Feb 2, 11:33 pm, Shino <shinoj....@gmail.com> wrote:
> I have 2 doubts while working with selenium RC and Ruby.  Could anyone
> please help me.
>
> 1. I recorded some test using selenium IDE
> 2. Exported the test with option "Ruby - Selenium RC".
> 3. Installed Ruby
> 4. Installed selenium client (gem install selenium-client)
> 5. I downloaded and set up Selenium RC in my machine.
> 6. I started selenium server from command prompt (-jar selenium-
> server.jar)
> 7. Now able to run the ruby scripts(rb file).
>
> Question 1: There is no test result/report generated after test run.
> Could anyone let me know how we can generate test result when we work
> with Selenium RC using ruby script ? Will Test Runner work with
> Selenium RC and Ruby combination? If so how?
>

To get started on how to automate report generation with RSpec. You
can look at a the selenium-client examples (http://github.com/ph7/
selenium-client/tree/6892a388b2dc5ba6e6bd7cc27a901bb76d0b7b4e/
examples) or the ones included in the Selenium Grid distribution
(http://github.com/ph7/selenium-grid/tree/
009d66b3fb5c1a974c3383938678aa9484214d70/examples/ruby) .

if you are already familiar with rake and RSpec just add in your
rakefile a task like:

require "rubygems"
require "spec"
require "selenium/client"
require "selenium/rspec/spec_helper"
require 'spec/rake/spectask'
desc 'Run acceptance tests for web application'
Spec::Rake::SpecTask.new(:'test:acceptance:web') do |t|
t.libs << "test"
t.pattern = "test/*_spec.rb"
t.spec_opts << '--color'
t.spec_opts << "--require 'rubygems,selenium/rspec/reporting/
selenium_test_report_formatter'"
t.spec_opts << "--
format=Selenium::RSpec::SeleniumTestReportFormatter:./tmp/
acceptance_tests_report.html"
t.spec_opts << "--format=progress"
t.verbose = true
end

You would then get reports like this one: http://ph7spot.com/examples/selenium_rspec_report.html

If you are still not familiar with Rake and RSpec I recommend you put
in place RSpec default reporting first (http://rspec.info,
http://www.railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial).

> Question 2: Is it possible to start selenium server from the ruby file
> which I am running? I mean, when I try to run my script, it should
> automatically start selenium server and at the end of test it should
> stop the server. Is there any way to do this from ruby file?
>

While this is possible I strongly recommend against having the tests
themselves start selenium RC. It is a lot more efficient and flexible
to automate Selenium RC start at the Rakefile level, and then have
your test tasks depend on it. This way you still get the benefit of
"it just works" when running your test suite but developing and
troubleshooting individual tests is a lot quicker and a lot more
efficient: You typically keep a Selenium RC running on your system
while you are editing and running the test.

If you buy that argument the selenium-client gem provides Rake task to
start stop Selenium RC (in the foreground or the background):

require 'rubygems'
require 'selenium-client'
require 'selenium/rake/tasks'
Selenium::Rake::RemoteControlStartTask.new do |rc|
rc.port = 4444
rc.timeout_in_seconds = 3 * 60
rc.background = true
rc.wait_until_up_and_running = true
rc.jar_file = "/path/to/where/selenium-rc-standalone-jar-is-
installed"
rc.additional_args << "-singleWindow"
end

Selenium::Rake::RemoteControlStopTask.new do |rc|
rc.host = "localhost"
rc.port = 4444
rc.timeout_in_seconds = 3 * 60
end

You can get more details about the selenium-client gem at
http://github.com/ph7/selenium-client/tree/master

The Selenium gem also offers similar functionalities (http://
selenium.rubyforge.org/document.html) and also bundles the RC jar.
Good luck,
- Philippe Hanrigou
http://ph7spot.com
Message has been deleted

SNK

unread,
Feb 5, 2009, 5:24:03 AM2/5/09
to selenium-ruby
Hi Philippe,

Thanks for your response. We would try with the details you mentioned
and let you know.

And with this my understanding is that, we will not be able to run/
control(similar to how we run HTML suits with selenium RC) the ruby
test sript suits with selenium-Test runner. Please confirm if this is
correct ?

Regards,
~Shino

Philippe Hanrigou

unread,
Feb 11, 2009, 1:38:09 AM2/11/09
to seleni...@googlegroups.com
Hi Shino,

On Thu, Feb 5, 2009 at 2:24 AM, SNK <shino...@gmail.com> wrote:
> And with this my understanding is that, we will not be able to run/
> control(similar to how we run HTML suits with selenium RC) the ruby
> test sript suits with selenium-Test runner. Please confirm if this is
> correct ?

Yes this is correct. In theory there is some ways to mix the two
approaches but let's not get into that... ;-)

Cheers,

Reply all
Reply to author
Forward
0 new messages