Sha256: 01663fef97a285beffb84a4ad4325d91365ef0440d39c5c6d4a2f069274dca30

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 KB

Contents

module WatirSpec
  class RemoteServer
    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.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

15 entries across 15 versions & 1 rubygems

Version Path
watir-6.13.0 lib/watirspec/remote_server.rb
watir-6.12.0 lib/watirspec/remote_server.rb
watir-6.11.0 lib/watirspec/remote_server.rb
watir-6.11.0.beta2 lib/watirspec/remote_server.rb
watir-6.11.0.beta1 lib/watirspec/remote_server.rb
watir-6.10.3 lib/watirspec/remote_server.rb
watir-6.10.2 lib/watirspec/remote_server.rb
watir-6.10.0 lib/watirspec/remote_server.rb
watir-6.9.1 lib/watirspec/remote_server.rb
watir-6.9.0 lib/watirspec/remote_server.rb
watir-6.8.4 lib/watirspec/remote_server.rb
watir-6.8.3 lib/watirspec/remote_server.rb
watir-6.8.2 lib/watirspec/remote_server.rb
watir-6.8.1 lib/watirspec/remote_server.rb
watir-6.8.0 lib/watirspec/remote_server.rb