Sha256: 5f297e0151ac6350ea64aba471fff240d7fd801f10b8a40f0ba3943a2016eee1

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module Selenium
  module Rake

    # Rake task to stop a Selenium Remote Control Server
    #
    # Selenium::Rake::RemoteControlStopTask.new do |rc|
    #   rc.host = "localhost"
    #   rc.port = 4444
    #   rc.timeout_in_seconds = 3 * 60
    # end
    #    
    class RemoteControlStopTask
      attr_accessor :host, :port, :timeout_in_seconds, :wait_until_stopped

      def initialize(name = :'selenium:rc:stop')
        @host = "localhost"
        @name = name
        @port = 4444
        @timeout_in_seconds = 5
        @wait_until_stopped = true
        yield self if block_given?
        define
      end
    
      def define
        desc "Stop Selenium Remote Control running"
        task @name do
          puts "Stopping Selenium Remote Control running at #{@host}:#{@port}..."
          remote_control = Selenium::RemoteControl::RemoteControl.new(@host, @port, @timeout_in_seconds)
          remote_control.stop
          if @wait_until_stopped
            TCPSocket.wait_for_service_termination :host => @host, :port => @port
          end
          puts "Stopped Selenium Remote Control running at #{@host}:#{@port}"
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
selenium-client-1.2.15 lib/selenium/rake/remote_control_stop_task.rb