Sha256: 507635039c26a3f83f97c448d6c987298324db6835af90489bceb8c6a373ba9e

Contents?: true

Size: 1.18 KB

Versions: 16

Compression:

Stored size: 1.18 KB

Contents

module WatirSpec
  class RemoteServer
    include Watir::Exception

    attr_reader :server

    def start(port = 4444, args: [])
      require 'selenium/server'

      @server ||= Selenium::Server.new(jar,
                                       port: Selenium::WebDriver::PortProber.above(port),
                                       log: !!$DEBUG,
                                       background: true,
                                       timeout: 60)
      args.each { |arg| @server << arg }
      @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.exist?(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 Error, 'unable to find or download selenium-server-standalone jar'
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
watir-7.0.0.beta4 lib/watirspec/remote_server.rb
watir-7.0.0.beta3 lib/watirspec/remote_server.rb
watir-7.0.0.beta2 lib/watirspec/remote_server.rb
watir-7.0.0.beta1 lib/watirspec/remote_server.rb
watir-6.19.1 lib/watirspec/remote_server.rb
watir-6.19.0 lib/watirspec/remote_server.rb
watir-6.18.0 lib/watirspec/remote_server.rb
watir-6.17.0 lib/watirspec/remote_server.rb
watir-6.16.5 lib/watirspec/remote_server.rb
watir-6.16.4 lib/watirspec/remote_server.rb
watir-6.16.3 lib/watirspec/remote_server.rb
watir-6.16.2 lib/watirspec/remote_server.rb
watir-6.16.1 lib/watirspec/remote_server.rb
watir-6.16.0 lib/watirspec/remote_server.rb
watir-6.15.1 lib/watirspec/remote_server.rb
watir-6.15.0 lib/watirspec/remote_server.rb