Skip to content

Instantly share code, notes, and snippets.

@pranav7
Last active April 8, 2021 13:03
Show Gist options
  • Save pranav7/0f377b91a8b2cafe71bd to your computer and use it in GitHub Desktop.
Save pranav7/0f377b91a8b2cafe71bd to your computer and use it in GitHub Desktop.
Installing Chromedriver and setting up Cucumber to run with Chrome on Linux/Ubuntu

Follow the below steps to install chrome webdrivers on Ubuntu

  • Install Unzip

sudo apt-get install unzip

  • Assuming you're running a 64-bit OS, download the latest version of chromedriver from their website

wget -N http://chromedriver.storage.googleapis.com/2.10/chromedriver_linux64.zip -P ~/Downloads unzip ~/Downloads/chromedriver_linux64.zip -d ~/Downloads

  • Make the file you downloaded executable, and move it to /usr/local/share
chmod +x ~/Downloads/chromedriver
sudo mv -f ~/Downloads/chromedriver /usr/local/share/chromedriver
  • Also, create symlinks to the chromedriver. Cucumber would look for the drivers in /usr/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
  • Finally, add/replace the below code in your features/support/env.rb
Capybara.register_driver :chrome do |app|
  # optional
  client = Selenium::WebDriver::Remote::Http::Default.new
  # optional
  client.timeout = 120
  Capybara::Selenium::Driver.new(app, :browser => :chrome, :http_client => client)
end

Capybara.javascript_driver = :chrome

And, you're good to go! Happy testing. ,,/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment