From: Ben Lovell Date: 2009-07-01T22:03:28+09:00 Subject: Re: Using selenium in a ruby program --001636c5b43b6f9750046da48c79 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Wed, Jul 1, 2009 at 12:43 PM, Kga Agk wrote: > I got it to work in ruby, but I have to start the selenium servver > manualy before I runn the program. That is unesesary mutch work and > complicated. Is there a way to start the selenium server inside the code > and stop it at the end? > > > Here is a code example i got to work... it is a bit messy > > > > require 'rubygems' > gem 'thoughtbot-shoulda' > require 'shoulda' > > > require 'spec' > require 'spec/story' > > require 'test/unit' > require "rubygems" > gem "selenium-client", ">=1.2.15" > require "selenium/client" > require "selenium" > > > describe "test" do > > before :all do > @browser = Selenium::Client::Driver.new \ > :host => "localhost", > :port => 4444, > :browser => "*firefox", > :url => "http://www.google.com", > :timeout_in_second => 60 > end > after :all do > @browser.close_current_browser_session > end > > > it "test1" do > @browser.start_new_browser_session > @browser.open "/" > @browser.type "q", "Selenium seleniumhq.org" > @browser.click "btnG", :wait_for => :page > assert @browser.text?("seleniumhq.org") > end > end > > > > > What do I need to add to get it to start the selenium server automaticly > and stop it at the end? > -- > Posted via http://www.ruby-forum.com/. > > You might want to take a look at Webrat if you haven't already [0] You can fairly easily switch between a simulated browser (if you don't need to test javascript) or run in automated mode i.e. selenium. [0] http://gitrdoc.com/brynary/webrat/tree/master/ Rgds, Ben --001636c5b43b6f9750046da48c79--