Skip to content

Instantly share code, notes, and snippets.

@ckenst
Last active November 29, 2017 22:16
Show Gist options
  • Save ckenst/3eeb34b2e33f9be7a0fb85a173f0ae00 to your computer and use it in GitHub Desktop.
Save ckenst/3eeb34b2e33f9be7a0fb85a173f0ae00 to your computer and use it in GitHub Desktop.
A previous example of headless chrome in Ruby using Selenium
# Using pry as our REPL of choice. Could also use irb
pry
require 'selenium-webdriver'
#set our driver to use chrome and pass in switches.
driver = Selenium::WebDriver.for :chrome, switches: %w[--headless --no-sandbox --disable-gpu --remote-debugin-port=9222]
#let's go to kenst.com & make sure we are on the page
driver.get 'http://www.kenst.com'
driver.title == "Chris Kenst's Blog"
#take a screen shot of the page
driver.save_screenshot('/Users/<username>/<location>/image1.png')
#close our browser
driver.quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment