Class: Chauffeur
- Inherits:
-
Object
- Object
- Chauffeur
- Defined in:
- lib/chauffeur.rb,
lib/chauffeur/setup.rb,
lib/chauffeur/path_expander.rb
Overview
Chauffeur adds WebDriver executables to the path
Drivers must be in path '{working_directory}/features/support/drivers/{os}/'
otherwise, the path must be passed in.
Defined Under Namespace
Modules: PathExpander, Setup
Class Method Summary collapse
-
.add_drivers_to_path ⇒ Object
Upgrades path to include the folder containing web drivers.
-
.downloader_for(browser, verbose = true) ⇒ Object
Returns a new downloader for the specified browser.
-
.driver_versions ⇒ Object
Returns a hash of the currently installed drivers.
-
.initialize_chauffeur ⇒ Object
Initialize method must be run before anything else will work.
-
.install_driver(browser, platform, version, verbose = true) ⇒ Object
Installs the specified version of specified driver for the specified platform.
-
.install_driver_all_platforms(browser, version, verbose = true) ⇒ Object
Installs the specified version of specified driver for all platforms.
-
.upgrade_driver(browser, platform, verbose = true) ⇒ Object
Installs the latest version of chromedriver for the specified platform.
-
.upgrade_driver_all_platforms(browser, verbose = true) ⇒ Object
Installs the latest version of specified driver for all platforms.
Class Method Details
.add_drivers_to_path ⇒ Object
Upgrades path to include the folder containing web drivers.
14 15 16 17 18 19 |
# File 'lib/chauffeur.rb', line 14 def add_drivers_to_path path = ENV['PATH'] new_paths = PathExpander.paths_to_add new_paths.reject! { |p| path.include?(p) } ENV['PATH'] = "#{new_paths.join(Gem.path_separator)}#{Gem.path_separator}#{path}" end |
.downloader_for(browser, verbose = true) ⇒ Object
Returns a new downloader for the specified browser. browser: string - chrome, edge, firefox, ie
69 70 71 |
# File 'lib/chauffeur.rb', line 69 def downloader_for(browser, verbose = true) Object.const_get("#{browser.capitalize}driverDownloader").new(verbose) end |
.driver_versions ⇒ Object
Returns a hash of the currently installed drivers.
22 23 24 25 |
# File 'lib/chauffeur.rb', line 22 def driver_versions config_file_path = "#{Dir.pwd}/drivers/config.yml" File.open(config_file_path) { |f| YAML.safe_load(f) }['installed_versions'] end |
.initialize_chauffeur ⇒ Object
Initialize method must be run before anything else will work.
9 10 11 |
# File 'lib/chauffeur.rb', line 9 def initialize_chauffeur Setup.create_folders_and_config end |
.install_driver(browser, platform, version, verbose = true) ⇒ Object
Installs the specified version of specified driver for the specified platform. browser - string, chrome, edge, firefox, ie platform - string, linux32, linux 64, mac32, win32 version: string - must match exactly the version in the download URL
52 53 54 55 56 |
# File 'lib/chauffeur.rb', line 52 def install_driver(browser, platform, version, verbose = true) raise "Unknown Browser '#{browser}'." unless valid_browser?(browser) downloader = downloader_for(browser, verbose) downloader.install_driver(version, platform) end |
.install_driver_all_platforms(browser, version, verbose = true) ⇒ Object
Installs the specified version of specified driver for all platforms. browser - string, chrome, edge, firefox, ie platforms - linux32, linux 64, mac32, win32
61 62 63 64 65 |
# File 'lib/chauffeur.rb', line 61 def install_driver_all_platforms(browser, version, verbose = true) raise "Unknown Browser '#{browser}'." unless valid_browser?(browser) downloader = downloader_for(browser, verbose) downloader.install_driver_all_platforms(version) end |
.upgrade_driver(browser, platform, verbose = true) ⇒ Object
Installs the latest version of chromedriver for the specified platform. browser - string, chrome, edge, firefox, ie platform - string, must match for browser
chrome: linux32, linux64, mac32, win32
edge: win
firefox: linux32, linux64, macos, win32, win64
ie: Win32, x64
34 35 36 37 38 |
# File 'lib/chauffeur.rb', line 34 def upgrade_driver(browser, platform, verbose = true) raise "Unknown Browser '#{browser}'." unless valid_browser?(browser) downloader = downloader_for(browser, verbose) downloader.upgrade_driver(platform) end |
.upgrade_driver_all_platforms(browser, verbose = true) ⇒ Object
Installs the latest version of specified driver for all platforms. browser - string, chrome, edge, firefox, ie
42 43 44 45 46 |
# File 'lib/chauffeur.rb', line 42 def upgrade_driver_all_platforms(browser, verbose = true) raise "Unknown Browser '#{browser}'." unless valid_browser?(browser) downloader = downloader_for(browser, verbose) downloader.upgrade_driver_all_platforms end |