CAPABILITY GENERATOR

LambdaTest DocumentationAutomation Testing ● Ruby with Selenium – Running Ruby Automation Scripts on LambdaTest Selenium Grid

Ruby with Selenium – Running Ruby Automation Scripts on LambdaTest Selenium Grid


LambdaTest provides support with Selenium WebDriver for pacing the execution of your automation test scripts. LambdaTest is a cloud-based, cross browser testing tool, providing a Selenium grid of 2000+ browsers and browser versions running through real operating systems to speed up automation testing of your web-app or website. This topic will help you to automate your website testing using Selenium with Ruby on LambdaTest.

This topic will be focusing on:

  1. Running a sample Selenium with Ruby on LambdaTest Automation.
  2. Setting up environment for testing your locally hosted web pages or website.
  3. Core Capabilities: understanding and configuring them in your Selenium test suite.
  4. Exploring advanced features of LambdaTest.

Prerequisites For Running Ruby With Selenium


First, you would have to install Ruby and gem on your local system. Installing these platforms is a little different in each operating system

  • For windows, you can download the latest installed here https://rubyinstaller.org/downloads/.
  • If you are using Linux or Ubuntu OS, you can run a simple apt command like below. You can also refer to this doc to know more about which command suits your OS better.
  • If you are using MacOS, you can run a homebrew command like this:
  • To run tests in parallel you will require the parallel_tests gem.
  • LambdaTest binary file for running tests on your locally hosted web pages.

Installing Selenium Dependencies For Ruby


Once you have ruby and gem setup, you would now have to install Selenium dependencies. Use the below gem command for installing Selenium:

Getting Started With Ruby & LambdaTest


Now that we are all set with prerequisites. It is time we look at a sample code, this code will validate if there is any change in the title of Google’s home page. This code is also available on our Ruby GitHub repository for you to clone and play around.

By using this code example, we will first validate your LambdaTest credentials for authentication purpose. Later, the code will select the basic capabilities such as OS, browser, browser version and so on.

The Selenium Webdriver test would open a URL, mark the first two items in the list as done, add an item in the list, and return the total number of pending item. Your results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on LambdaTest dashboard. LambdaTest Dashboard will help you view all your text logs, screenshots and video recording for your entire Selenium tests.

Executing The Test


You would need to execute the below command in your terminal/cmd.

Understanding & Configuring Ruby Desired Capabilities


As we said earlier the first step is to configure your test scripts to connect with LambdaTest Selenium automation gird. In the above mentioned Ruby code, the first thing you would notice is the invoking of remote webdriver instead of the native browser webdrivers. So for example if you are planning to run on Firefox browser in your local machine, you would be using Firefox browser driver like this:

Local Driver

However, to run on LambdaTest Selenium grid, you would have to change it remote webdriver and at the same time pass capabilities related to browser, browser versions etc. This is how you code would look like:

Remote Web Driver

To read about all the Selenium and custom capabilities offered by LambdaTest, visit our Selenium Automation Capabilities document.

LambdaTest Capabilities Generator will automatically generate the program, based on your provided input. For Instance, if you select the below configurations:

Capability
Selected Value
Selenium Version
3.13.0
Resolution
1920×1080
Operating System
OS X Yosemite
Browser Version
71.0
Browser
Google Chrome

Then, LambdaTest Capabilities Generator will automatically generate the below program:

The most important capabilities to understand here are ‘browserName’, ‘versions’, and ‘platform’. They define which browser environment you wish to run the test on. Rest of the capabilities are important in test management and debugging. We have an inbuilt capabilities generator tool as well that you use to generate capabilities code for your test suite.

Advanced LambdaTest Capabilities


In addition to default Selenium Grid capabilities, LambdaTest also has platform specific capabilities like a video recording of test runs, console logs of each test run, network logs of each test run, custom profiles for specific browsers, etc. Do checkout our documentations on LambdaTest Advanced capabilities as well.

Testing Locally Hosted or Privately Hosted Projects


Perform cross browser testing on your locally hosted web app or website using Lambda Tunnel for identifying bugs before your website goes live. This tunnel would help to establish an SSH(Secure Shell) connection for hosting your locally stored web pages from your local machine to LambdaTest cloud servers. You can use Lambda Tunnel to perform cross browser testing on the web-apps or websites which may only be accessible within your organization’s firewall. You can even perform local host testing through different geographic IP to analyze how your website would work when accessed from different continents of the world. Wish to know more about Lambda Tunnel?

Follow our documentation on Lambda Tunnel to know it all. OS specific instructions to download and setup tunnel binary can be found at the following links.

If you are done with the download of binary file then open your cmd(Command Prompt) / terminal and move the pointer to the same location where the binary zip file is extracted in your system. Type the below command and hit Enter for launching the SSH connection through Lambda Tunnel.

For example, If you have the following:

Field
Example Values
Login Email
LoremIpsum@lambdatest.com
Access Key
987zyx987

Then, the command would be:

The above command will set up Lambda Tunnel successfully! Now, for performing automation testing using Selenium with Ruby you need to add the below to your capabilities.

You may also use LambdaTest Capabilities Generator for providing you with the above capability.

Mark Status As Pass or Fail


While performing automation testing using Selenium with Ruby on LambdaTest selenium grid, it is imperative to flag an automation test as either pass or fail. This is completely dependent on your testing requirement with respect to the validation of expected behaviour. You can mark whether an automation test passed or fail by adding the below code fragment in your automation script.

Queuing


If you have more test cases to run than your concurrency limit then you can rack them up in queue. However, to prevent the LambdaTest platform from over-exploitation, we have defined a limit on the maximum queuing capacity.

At LambdaTest, your maximum queue capacity is dependent upon your concurrent user sessions. The following formula would help you to calculate your queuing potential.

Maximum Queue Capacity

Maximum number of test cases that can be queued = n + 150

Here, n = number of concurrent sessions.

For example, if you are opting for a pricing where you can avail up to 10 concurrent sessions. Then the maximum number of test cases that can be queued will be equal to 10 + 150 i.e. 160 queued test cases. Queuing allows you to manage your test pipeline in a hassle-free manner. The process of scheduling and executing the test cases is automatically handled by LambdaTest for you.

LambdaTest Queuing Policy: Follow out LambdaTest Queuing Policy to know more.

Queuing Timeout

There is also a limit on how long a test case can stay in the queue. If your test case stays in the queue for more than 15 minutes, the test case would be timed out and would not be executed.