Class: WebDriverManager::ChromeDriver
- Inherits:
-
Object
- Object
- WebDriverManager::ChromeDriver
show all
- Extended by:
- Support
- Defined in:
- lib/webdriver_manager/drivers/driver_chrome.rb
Class Method Summary
collapse
Methods included from Support
latest_binary, provision, provision_driver, remove_binary
Class Method Details
.current_binary ⇒ Object
8
9
10
11
12
13
14
15
16
|
# File 'lib/webdriver_manager/drivers/driver_chrome.rb', line 8
def current_binary
WebDriverManager.logger.debug("Checking Current Driver Version")
return nil unless driver_is_downloaded?
binary_version = `#{driver_binary} --version`
WebDriverManager.logger.debug(
"Current version of #{driver_binary} is #{binary_version}"
)
normalize(binary_version.match(/ChromeDriver (\d+\.\d+)/)[1])
end
|
.driver_base_url ⇒ Object
22
23
24
|
# File 'lib/webdriver_manager/drivers/driver_chrome.rb', line 22
def driver_base_url
"http://chromedriver.storage.googleapis.com"
end
|
.driver_binary_list ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/webdriver_manager/drivers/driver_chrome.rb', line 26
def driver_binary_list
unless driver_url_is_reachable?
raise StandardError, "Unable to Access the Driver URL"
end
@binaries ||= begin
files = process_binary_files
process_binary_versions(files)
end
end
|
.driver_name ⇒ Object
18
19
20
|
# File 'lib/webdriver_manager/drivers/driver_chrome.rb', line 18
def driver_name
os_platform == "win" ? "chromedriver.exe" : "chromedriver"
end
|
.normalize(string) ⇒ Object
This method makes sure that versions are stored with the same style. For example, 2.10 will be stored exactly as that. But 2.9 will be stored as 2.09.
59
60
61
|
# File 'lib/webdriver_manager/drivers/driver_chrome.rb', line 59
def normalize(string)
string.size == 3 ? string.gsub('.', '.0').to_f : string.to_f
end
|
.process_binary_files ⇒ Object
37
38
39
40
41
|
# File 'lib/webdriver_manager/drivers/driver_chrome.rb', line 37
def process_binary_files
resource = Nokogiri::XML.parse(get(driver_base_url))
files = resource.css("Contents Key").collect(&:text)
files.select! { |file| file.include?(os_platform) }
end
|
.process_binary_versions(files) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/webdriver_manager/drivers/driver_chrome.rb', line 43
def process_binary_versions(files)
binary_list = files.each_with_object({}) do |file, binary|
version = normalize(file[%r{^[^\/]+}])
binary[version] = "#{driver_base_url}/#{file}"
end
WebDriverManager.logger.debug(
"Versions Located at Driver URL: #{binary_list.keys}"
)
binary_list
end
|