Library for controlling and interacting with browsers for testing selenium testing
0.12.0 Latest release released

Selenium client for interacting with web pages for browser automation.

API Documentation


  1. Add the dependency to your shard.yml:

        github: matthewmcgarvey/
  2. Run shards install


require "selenium"

Creating a Driver

driver = Selenium::Driver.for(:chrome, base_url: "http://localhost:9515")

Creating a driver this way assumes that you have the driver running already.

Available drivers:

  • :chrome (using chromedriver)
  • :firefox (using geckodriver)
  • :remote (general purpose)

Running with a service

Rather than running chromedriver yourself, you can give the driver a service which will run the process for you.

service = File.expand_path("~/.webdrivers/chromedriver", home: true))
driver = Selenium::Driver.for(:chrome, service: service)

You must call driver.stop when you are finished or it will leave the service running. Consider using for automatically installing drivers and managing the driver path for you.

Creating a Session

capabilities =
capabilities.chrome_options.args = ["no-sandbox", "headless", "disable-gpu"]

Use the appropriate Capabilities class for whichever browser you choose.


Run crystal spec to run the tests. It will run the tests in headless mode.

To run the tests with chrome headlessly:

SELENIUM_BROWSER=chrome crystal spec --tag "~chrome"

To run the tests with firefox headlessly:

SELENIUM_BROWSER=firefox crystal spec --tag "~firefox"

The tag skips any specs that are know to break with those browsers. Running just crystal spec will use chrome.


  1. Fork it (
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request


  github: matthewmcgarvey/
  version: ~> 0.12.0
License MIT
Crystal >= 1.4.0, < 2.0.0


Dependencies 0

Development Dependencies 2

  • ameba ~> 1.4.3
    {'github' => 'crystal-ameba/ameba', 'version' => '~> 1.4.3'}
  • webdrivers~crystal-loot ~> 0.4.2
    {'github' => 'crystal-loot/', 'version' => '~> 0.4.2'}

Dependents 1

Last synced .
search fire star recently