diff --git a/README.md b/README.md index 8dc9cf8..27cffb3 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ end Habitat.raise_if_missing_settings! ``` -Then install Chromedriver and view the guides: https://luckyframework.org/guides/browser-tests/ +Then view the guides: https://luckyframework.org/guides/browser-tests/ You should be ready to go! @@ -61,4 +61,4 @@ View guide at: https://luckyframework.org/guides/browser-tests/ ## Contributors -* [paulcsmith](https://github.com/paulcsmith) Paul Smith - creator, maintainer +- [paulcsmith](https://github.com/paulcsmith) Paul Smith - creator, maintainer diff --git a/src/lucky_flow/chromedriver.cr b/src/lucky_flow/chromedriver.cr index a32d2ae..8e14fe6 100644 --- a/src/lucky_flow/chromedriver.cr +++ b/src/lucky_flow/chromedriver.cr @@ -6,7 +6,6 @@ class LuckyFlow::Chromedriver getter log_io = IO::Memory.new private def initialize - ensure_chromedriver_is_installed @process = start_chromedriver end @@ -14,21 +13,9 @@ class LuckyFlow::Chromedriver new end - private def ensure_chromedriver_is_installed - if !Process.find_executable("chromedriver") - raise <<-ERROR - Chromedriver must be available from the command line to use LuckyFlow. - - ▸ On macOS: brew install chromedriver - ▸ On Linux: https://makandracards.com/makandra/29465-install-chromedriver-on-linux - - ERROR - end - end - private def start_chromedriver : Process Process.new( - "chromedriver", + "#{__DIR__}/../../vendor/chromedriver-2.40-#{os}", ["--port=4444", "--url-base=/wd/hub"], output: log_io, error: STDERR, @@ -36,6 +23,17 @@ class LuckyFlow::Chromedriver ) end + private def os + os_name = IO::Memory.new + Process.run("uname -a", shell: true, output: os_name, error: STDERR) + + if os_name.to_s.includes?("Darwin") + "mac64" + else + "linux64" + end + end + def stop process.kill unless process.terminated? end diff --git a/vendor/chromedriver-2.40-linux64 b/vendor/chromedriver-2.40-linux64 new file mode 100755 index 0000000..cdfd6dd Binary files /dev/null and b/vendor/chromedriver-2.40-linux64 differ diff --git a/vendor/chromedriver-2.40-mac64 b/vendor/chromedriver-2.40-mac64 new file mode 100755 index 0000000..773f1e1 Binary files /dev/null and b/vendor/chromedriver-2.40-mac64 differ