Class: IedriverDownloader

Inherits:
DriverDownloader show all
Defined in:
lib/chauffeur/downloaders/iedriver_downloader.rb

Overview

IEDriver specific functions for driver downloading.

Constant Summary collapse

IEDRIVER_URL =
'http://selenium-release.storage.googleapis.com/'.freeze

Instance Method Summary collapse

Methods inherited from DriverDownloader

#download_and_unzip, #install_driver, #install_driver_all_platforms, #path_for, #upgrade_driver, #upgrade_driver_all_platforms

Constructor Details

#initialize(verbose = true) ⇒ IedriverDownloader

Returns a new instance of IedriverDownloader.



5
6
7
8
# File 'lib/chauffeur/downloaders/iedriver_downloader.rb', line 5

def initialize(verbose = true)
  @all_driver_versions = all_driver_versions
  super(verbose)
end

Instance Method Details

#all_driver_versionsObject

Returns all available versions of iedriver



32
33
34
35
36
# File 'lib/chauffeur/downloaders/iedriver_downloader.rb', line 32

def all_driver_versions
  resp = HTTParty.get(IEDRIVER_URL).parsed_response
  contents = resp['ListBucketResult']['Contents']
  contents.map { |c| c['Key'] }.select { |url| url.include?('IEDriverServer') }
end

#all_platformsObject



18
19
20
# File 'lib/chauffeur/downloaders/iedriver_downloader.rb', line 18

def all_platforms
  %w[Win32 x64]
end

#browser_nameObject



10
11
12
# File 'lib/chauffeur/downloaders/iedriver_downloader.rb', line 10

def browser_name
  'iedriver'
end

#driver_download_url(version, platform) ⇒ Object

Returns the url for the desired version of iedriver version: string - must match exactly the version in the download URL platform: string - must be one of: linux32, linux64, mac32, win32



41
42
43
44
45
46
47
48
# File 'lib/chauffeur/downloaders/iedriver_downloader.rb', line 41

def driver_download_url(version, platform)
  raise unknown_platform_error(platform) unless valid_platform?(platform)
  rel_path = @all_driver_versions.find do |v|
    v =~ %r{#{version}/IEDriverServer_#{platform}_#{version}\.\d+\.zip}
  end
  raise unknown_version_error(version) unless rel_path
  "#{IEDRIVER_URL}#{rel_path}"
end

#driver_urlObject



14
15
16
# File 'lib/chauffeur/downloaders/iedriver_downloader.rb', line 14

def driver_url
  IEDRIVER_URL
end

#latest_driver_version(platform) ⇒ Object

Returns the most recent version of iedriver for the desired platform. platform must be one of: linux32, linux64, mac32, win32



25
26
27
28
29
# File 'lib/chauffeur/downloaders/iedriver_downloader.rb', line 25

def latest_driver_version(platform)
  raise unknown_platform_error(platform) unless valid_platform?(platform)
  platform_drivers = @all_driver_versions.select { |v| v.include?(platform) }
  platform_drivers.map { |v| version_of(v.split('/')[0]) }.max
end