Sha256: c8b19d8be7dba99a430394815ed6a2ced534176c078a3f0ce239ea6b74851f33

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

module WatirSpec
  class RemoteServer
    attr_reader :server

    def start(port = 4444)
      require 'selenium/server'

      @server ||= Selenium::Server.new(jar,
                                       port: Selenium::WebDriver::PortProber.above(port),
                                       log: !!$DEBUG,
                                       background: true,
                                       timeout: 60)
      @server.start
      at_exit { @server.stop }
    end

    private

    def jar
      if ENV['LOCAL_SELENIUM']
        local = File.expand_path('../selenium/buck-out/gen/java/server/src/org/openqa/grid/selenium/selenium.jar')
      end

      if File.exist?(ENV['REMOTE_SERVER_BINARY'] || '')
        ENV['REMOTE_SERVER_BINARY']
      elsif ENV['LOCAL_SELENIUM'] && File.exists?(local)
        local
      elsif !Dir.glob('*selenium*.jar').empty?
        Dir.glob('*selenium*.jar').first
      else
        Selenium::Server.download :latest
      end
    rescue SocketError
      # not connected to internet
      raise Watir::Exception::Error, "unable to find or download selenium-server-standalone jar"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
watir-6.7.3 lib/watirspec/remote_server.rb
watir-6.7.2 lib/watirspec/remote_server.rb
watir-6.7.1 lib/watirspec/remote_server.rb
watir-6.7.0 lib/watirspec/remote_server.rb
watir-6.6.3 lib/watirspec/remote_server.rb
watir-6.6.2 lib/watirspec/remote_server.rb
watir-6.6.1 lib/watirspec/remote_server.rb
watir-6.6.0 lib/watirspec/remote_server.rb