sudo apt-get update
sudo apt-get install -y firefox
firefox --version
https://github.com/mozilla/geckodriver/releases
wget https://github.com/mozilla/geckodriver/releases/download/v0.28.0/geckodriver-v0.28.0-linux64.tar.gz
tar zxvf geckodriver-v0.28.0-linux64.tar.gz
chmod +x geckodriver
sudo mv -f geckodriver /usr/local/share/geckodriver
sudo ln -s /usr/local/share/geckodriver /usr/local/bin/geckodriver
sudo ln -s /usr/local/share/geckodriver /usr/bin/geckodriver
--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"
opts = Selenium::WebDriver::Firefox::Options.new(args: ['--headless'])
driver = Selenium::WebDriver.for(:firefox, options: opts)
driver.navigate.to "https://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