Skip to content

Instantly share code, notes, and snippets.

@c-lliope
Created November 4, 2018 14:27
Show Gist options
  • Save c-lliope/9252fb96f4b1656695e9d110305ada91 to your computer and use it in GitHub Desktop.
Save c-lliope/9252fb96f4b1656695e9d110305ada91 to your computer and use it in GitHub Desktop.
require "selenium-webdriver"
require "capybara"
Capybara.register_driver :containerized_selenium do |app|
Capybara::Selenium::Driver.new(
app,
browser: :remote,
url: "http://selenium:4444/wd/hub",
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox
)
end
web = Capybara::Session.new(:containerized_selenium)
web.visit("http://example.com")
puts web.html
version: '3.3'
services:
selenium:
image: selenium/standalone-firefox-debug
volumes:
# The images need access to the hosts' shared memory;
# see https://github.com/SeleniumHQ/docker-selenium#running-the-images
- /dev/shm:/dev/shm
expose:
- 4444
- 9515
spec:
image: ruby
links:
- selenium
require "selenium-webdriver"
driver = Selenium::WebDriver.for :remote, url: "http://selenium:4444/wd/hub", desired_capabilities: :firefox
driver.navigate.to("http://example.com")
puts driver.title
driver.quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment