Reputation: 197
Has anyone successfully set up a standalone environment for using ruby 1.9.2, selenium-client, and rspec to test a NON-RAILS website.
I have scoured the web but I cannot seem to get the magic formula. There are gem version conflicts, missing libraries, etc. At this point I am totally confused.
BASIC PROBLEM: I have many test suites and tests ceated using SeleniumIDE 1.0.10 for a NON-RAILS application (IIS/ASP). I SIMPLY want to use the converted tests that the SeleniumIDE can provide and run them using ruby or better yet rake. (Note that the SeleniumIDE can create RSpec or Test/Unit tests and I would be love to get either working).
As I understand it the selenium-client has rake tasks to start/stop the SeleniumRC server and to run tests. But for the life of me I cannot get any of this this going.
I can provide more information if need be. But, at this point I would be happy to know of anyone that is also going down this road.
-Thanks!
P.S. I am doing this as a prelude to hybridizing the IIS/ASP application with rails and iteratively going to a full conversion. If I cannot get this first step going my bosses are going to nix the whole idea of going to rails, so please help ;-)
Upvotes: 2
Views: 1273
Reputation: 1899
You will need to gem install 'rspec' and 'selenium-client'. I have ruby 1.9.2 installed and yes, I use rvm. I apologize for the firefox_version nonsense. I have multiple firefox versions installed on my Macbook. If you have a single firefox installed then simply specify :browser => "*firefox"
You will need to open two Terminal windows. In the first, start the selenium-server.jar.
In the second window, cd to the directory containing rspec_hello.rb and enter ruby ./rspec_hello.rb
Here is rspec_hello.rb
require "rubygems" # >= 1.8.12
require 'rspec' # >= 2.1.0
require "selenium/client" # >= 1.2.18
describe "google" do
# attr_reader :selenium_driver
@selenium_driver = nil
before(:each) do
firefox_version = 3
firefox_path = "/Applications/Firefox" + firefox_version.to_s + ".app/Contents/MacOS/firefox-bin"
@selenium_driver = Selenium::Client::Driver.new \
:host => "localhost",
:port => 4444,
:browser => "*firefox #{firefox_path}",
:url => "http://www.google.com/",
:timeout_in_second => 60
@selenium_driver.start
end
after(:each) do
puts " "
puts "goodbye world"
@selenium_driver.close_current_browser_session
end
it "test google" do
puts "hello world"
@selenium_driver.open "/"
@selenium_driver.type "q", "selenium wiki"
@selenium_driver.click "btnG"
@selenium_driver.wait_for_text("Selenium Wiki")
@selenium_driver.text?("Selenium Wiki").should be_true
end
end
Upvotes: 2
Reputation: 197
I use rvm and bundler when working with rails. For the project I am concerned about in this question I did not want to have a separate environment for the stand-alone tests of the OLD stuff (IIS/ASP).
So, I decided to use the Test:Unit Selenium conversions instead of RSpec, along with some rake tasks to do the testing stand-alone in the same environment as the hybrid project.
This made sense because almost all of these selenium tests are testing the OLD half of the hybrid system and will be replaced with rspec/cucumber/capybara tests for the NEW rails code as it is integrated, until the OLD half (along with the stand alone tests) are no more.
There are still uses for selenium in the NEW integrated rails only project, especially for AJAX testing.
See this railscast for an example.
Upvotes: 0