Last active
November 29, 2017 22:16
-
-
Save ckenst/3eeb34b2e33f9be7a0fb85a173f0ae00 to your computer and use it in GitHub Desktop.
A previous example of headless chrome in Ruby using Selenium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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