Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple selenium script using chrome headless
require 'selenium-webdriver'
require 'rspec/expectations'
include RSpec::Matchers
def setup
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument('--remote-debugging-port=9222')
@driver = Selenium::WebDriver.for :chrome, options: options
end
def teardown
@driver.quit
end
def run
setup
yield
teardown
end
run do
@driver.get 'http://www.kenst.com/about'
expect(@driver.title).to eql "About – Chris Kenst's Blog"
@driver.save_screenshot(File.join(Dir.pwd, "headless.png"))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.