Use selenium (Chrome) in Ruby in WSL environment

Use selenium (Chrome) in Ruby in WSL environment

Advance preparation

Installation of required libraries

sudo apt-get update
sudo apt-get install -y libappindicator1 fonts-liberation

Install chrome that can use headless mode

sudo apt install gdebi-core wget unzip
sudo gdebi google-chrome-stable_current_amd64.deb

Check Chrome version

google-chrome --version

chrome driver installation

Download the chromedriver for the currently installed google-chrome

curl -O
chmod +x chromedriver
sudo mv -f chromedriver /usr/local/share/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver

Operation check

--Package change


source ""

git_source(:github) {|repo_name| "{repo_name}" }

gem "webdriver"
gem "selenium-webdriver"

--Package reflection

bundle install

--Ruby sample code


require "selenium-webdriver"

options =

driver = Selenium::WebDriver.for(
  options: options
) ""

puts driver.title


--Operation check

ruby test.rb


--How to test Ruby with Selenium WebDriver [For beginners]

--Run Headless chrome on Ruby and Selenium on Ubuntu/Linux

-[Complete version] Cheat sheet that automatically operates (crawling / scraping) the browser with Python and Selenium

Recommended Posts

Use selenium (Chrome) in Ruby in WSL environment
Use selenium (Firefox) in Ruby in WSL environment
Install ruby serial port in WSL environment
Update Ruby in Unicorn environment
Use ruby variables in javascript.
WSL2 + Ubuntu 20.04 Install Vivado in LTS environment
[Docker] Use environment variables in Nginx conf
How to use environment variables in RubyOnRails
I want to use arrow notation in Ruby
Class in Ruby
Heavy in Ruby! ??
[Rails] How to use PostgreSQL in Vagrant environment
Use Shift Right and Shift Left properly in Selenium
[Ruby] How to use standard output in conditional branching
People who don't usually use Ruby build a Ruby environment
Install Rust in WSL2 Ubuntu environment and build WASM build environment
Beginners use ubuntu in windows to prepare rails environment
Use Coveralls with GitHub Actions in a Ruby repository
Handling of date and time in Ruby. Use Date and Time properly.
Use java.time in Jackson
Use Interceptor in Spring
Use OpenCV in Java
Use MouseListener in Processing
Use images in Rails
Output triangle in Ruby
Use PostgreSQL in Scala
Variable type in ruby
Use PreparedStatement in Java
Fast popcount in Ruby
About docker.credentials.errors.StoreErrorTraceback in wsl2
Install / run a standalone robot simulator in wsl2 / docker environment!
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
Use Java Web Start in an OpenJDK environment on Windows
Use docker-compose.yml which is different for each environment in Makefile