sudo apt-get update
sudo apt-get install -y libappindicator1 fonts-liberation
sudo apt install gdebi-core wget unzip
sudo gdebi google-chrome-stable_current_amd64.deb
google-chrome --version
Download the chromedriver for the currently installed google-chrome https://sites.google.com/a/chromium.org/chromedriver/
curl -O https://chromedriver.storage.googleapis.com/87.0.4280.88/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
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
--Package change
Gemfile
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "webdriver"
gem "selenium-webdriver"
--Package reflection
bundle install
--Ruby sample code
test.rb
require "selenium-webdriver"
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--no-sandbox')
driver = Selenium::WebDriver.for(
:chrome,
options: options
)
driver.navigate.to "https://www.google.com/"
puts driver.title
driver.quit
--Operation check
ruby test.rb
--How to test Ruby with Selenium WebDriver [For beginners] https://techacademy.jp/magazine/18704
--Run Headless chrome on Ruby and Selenium on Ubuntu/Linux https://qiita.com/meguroman/items/41ca17e7dc66d6c88c07
-[Complete version] Cheat sheet that automatically operates (crawling / scraping) the browser with Python and Selenium https://tanuhack.com/selenium/
Recommended Posts