How to Run Selenium Tests With Ruby on TestMu AI
Run your Ruby Selenium tests on the TestMu AI cloud grid across 10,000+ browser/device combinations. The setup is the same for every framework: you connect to the grid and pass your capabilities. This guide covers that shared flow once, then gives you a per-framework quickstart in the tabs below.
Prerequisites
- Create a TestMu AI account if you don't have one.
- Get your Username and Access Key from the TestMu AI Dashboard.
- Install Ruby and the
gempackage manager. - Install the
selenium-webdrivergem (andparallel_testsfor parallel runs), pulled in by the sample projects via Bundler.
Set Your Credentials
Your Username and Access Key are read from environment variables, set once per operating system.
Every framework authenticates the same way: your Username and Access Key are read from environment variables. Set them once. Pick your operating system:
Verified- macOS / Linux
- Windows (CMD)
export LT_USERNAME="undefined"
export LT_ACCESS_KEY="undefined"
set LT_USERNAME=undefined
set LT_ACCESS_KEY=undefined
How the Sample Test Works
Every framework below connects to the grid and passes your browser and OS choices through a capabilities hash:
Verifiedcaps = {
:browserName => "chrome",
:version => "latest",
:platform => "Windows 10",
:name => "Ruby Selenium Test",
:build => "Ruby Selenium Build",
:video => true
}
What changes between frameworks is only how the test is structured and launched. That is what each tab covers.
Use the Capabilities Generator to build a capabilities block for any browser, version, and OS combination.
Run a Test in Your Framework
Each tab lists the framework-specific pieces. Clone the matching repo (it contains the full, ready-to-run project), then run.
- Capybara
- RSpec
- Test::Unit
Capybara runs with Cucumber for BDD-style tests, driven by Bundler and Rake tasks.
- Clone the sample GitHub project:
git clone https://github.com/LambdaTest/Capybara-Cucumber-Ruby
cd Capybara-Cucumber-Ruby
- Set your browser and OS in the capabilities hash:
@caps = {
"browserName" => "chrome",
"browserVersion" => "latest",
"platformName" => "Windows 10",
"build" => "capybara-lambdatest",
"name" => "single-Test"
}
- Install the project dependencies:
bundle install
- Run a single test, or in parallel:
bundle exec rake single
bundle exec rake parallel
The test then appears on the Automation Dashboard. A green status confirms it passed.
RSpec loads capabilities from config YAML files and passes them to the remote WebDriver, run via Rake tasks.
- Clone the sample GitHub project:
git clone https://github.com/LambdaTest/RSpec-Selenium-Sample
cd RSpec-Selenium-Sample
- Set your browser and OS in the config YAML.
- Install the project dependencies:
bundle install
- Run a single test, or in parallel:
bundle exec rake single
bundle exec rake parallel
The test then appears on the Automation Dashboard. A green status confirms it passed.
Test::Unit runs a Ruby test file directly, with capabilities inline, and no Bundler task runner.
- Clone the sample GitHub project:
git clone https://github.com/LambdaTest-sample-test-frameworks/Ruby-UnitTest-Selenium
cd Ruby-UnitTest-Selenium
- Set your browser and OS in the capabilities hash:
caps = {
:browserName => "chrome",
:browser_version => "latest",
:platform_name => "Windows 10",
:name => "UnitTest Sample Test",
:build => "UnitTest Selenium Build"
}
- Install the project dependencies:
bundle install
- Run the test:
ruby LambdaTest.rb
The test then appears on the Automation Dashboard. A green status confirms it passed.
View Your Results
Your test results, including video, network logs, and command-by-command execution, appear on the TestMu AI Automation Dashboard.
Next steps: If this is your first run, walk through running your first Selenium test end to end. From there, explore the full set of Selenium automation capabilities you can pass to the grid, learn how to debug your Selenium tests, and organize and filter your Selenium tests as your suite grows.
Next Steps
Continue with these related guides:
