Created
September 4, 2018 22:42
-
-
Save ckenst/38e1651793cf8955d605ac72697682da to your computer and use it in GitHub Desktop.
Selenium Test written in Ruby using the Chrome Docker Container
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
require 'selenium-webdriver' | |
require 'rspec/expectations' | |
include RSpec::Matchers | |
def setup | |
caps = Selenium::WebDriver::Remote::Capabilities.send("chrome") | |
# This url is the local access url of the docker container | |
@driver = Selenium::WebDriver.for(:remote, url: "http://0.0.0.0:4444/wd/hub", desired_capabilities: caps) | |
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" | |
@driver.save_screenshot('docker_image.png') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment