Run your RC server via Rakefile
Gone tired of starting your selenium server by typing,
“java -jar selenium-server.jar"
from your console or if you’re luckier create a batch file then run it to start your server...
Here’s a more powerful tool to do it. Utilizing the selenium-client ruby gem, first you need to create a rakefile and define the tasks that you want to do. For instance we want to tell our rake to do the following tasks:
1. Start selenium server,
2. Stop selenium server, and
3. Restart selenium server
require 'rubygems' require 'selenium/rake/tasks' # use selenium rc rake tasks that are bundled with the selenium-client gem SELENIUM_RC_JAR = Dir[File.dirname(__FILE__) + "/selenium-server*.jar"].first # Start selenium server task Selenium::Rake::RemoteControlStartTask.new(:'rc:start') do |rc| rc.port = 4444 rc.timeout_in_seconds = 3 * 60 rc.background = true rc.wait_until_up_and_running = true rc.jar_file = SELENIUM_RC_JAR rc.additional_args << " -multiWindow -firefoxProfileTemplate FirefoxProfile" end # Stop selenium server task Selenium::Rake::RemoteControlStopTask.new(:'rc:stop') do |rc| rc.host = "localhost" rc.port = 4444 rc.timeout_in_seconds = 3 * 60 end # Restart selenium server task desc "Restart Selenium Remote Control" task :'rc:restart' do Rake::Task[:"rc:stop"].execute [] rescue nil Rake::Task[:"rc:start"].execute [] end
In your console go to the root folder where your rake file is saved, type
“rake -T” or “rake –task”
D:\Projects>rake -T
Console will list all available tasks defined in the rake:
(in D:/Projects)
rake rc:restart # Restart Selenium Remote Control
rake rc:start # Launch Selenium Remote Control
rake rc:stop # Stop Selenium Remote Control running
From this list you can restart/start/close the server by simply invoking the commands e.g. rake rc:start
thanks, helped me a lot