Socket
Book a DemoInstallSign in
Socket

testcontainers-selenium

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testcontainers-selenium

0.2.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Testcontainers module for Selenium

Installation

Add the library to the test section in your application's Gemfile:

group :test do
  gem 'testcontainers-selenium'
end

And then execute:

$ bundle install

Or install it yourself as:

$ gem install testcontainers-selenium

Usage

To use the library, you first need to require it:

require "testcontainers/selenium"

Creating a Selenium Container

Create a new instance of the Testcontainers::SeleniumContainer class:

container = Testcontainer::SeleniumContainer.new

This creates a new container with the default Selenium configuration for firefox, the vnc password will be secret. You can customise by passing arguments to the constructor:

container = Testcontainer::SeleniumContainer.new(capabilities: :chrome, vnc_no_password: true)

Starting and Stopping a container

Start the container

container.start

Stop the container when you're done

container.stop

Connecting to the Selenium container

Once the container is running, you can obtain the connection details using the following methods:

host = container.host
post = container.first_mapped_port

Or, you can generate a full Selenium URL

selenium_url = container.selenium_url

Examples

There are complete examples of how to use testcontainers-selenium to create containers, connects to it, and navigate through different browsers:

require "testcontainers/selenium"
require "selenium-webdriver"

container = Testcontainer::SeleniumContainer.new
container.start

driver = Selenium::WebDriver.for(:firefox, :url => @container.selenium_url)

driver.navigate.to "https://www.google.com"

driver.screenshot

The previous example creates a container and after create a client for do a connections wiht the google page,finally we take a screenshot from the current page

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/testcontainers/testcontainers-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Testcontainers project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 09 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.