Class: Testcontainers::SeleniumContainer
- Inherits:
-
DockerContainer
- Object
- DockerContainer
- Testcontainers::SeleniumContainer
- Defined in:
- lib/testcontainers/selenium.rb
Overview
SeleniumContainer class is used to manage containers that runs a automaticates test
Constant Summary collapse
- SELENIUM_DEFAULT_PORT =
Default ports used by the container
4444
- VNC_DEFAULT_PORT =
5900
- SE_VNC_PASSWORD =
1
- SELENIUM_IMAGES =
Hash that contains the images for the build of the containers of selenium that runs in the browsers chrome and firefox
{ firefox: "selenium/standalone-firefox:latest", chrome: "selenium/standalone-chrome:latest" }
Instance Attribute Summary collapse
-
#headless ⇒ Object
readonly
Returns the value of attribute headless.
Instance Method Summary collapse
-
#initialize(image = nil, capabilities: :firefox, headless: false, vnc_no_password: nil, vnc_password: nil, **kwargs) ⇒ SeleniumContainer
constructor
Initializes a new instance of SeleniumContainer.
-
#port ⇒ Integer
Returns the port used by the container.
-
#selenium_url(protocol: "http://") ⇒ String
Returns the selenium connection url (e.g host:port/wd/hub).
-
#start ⇒ SeleniumContainer
Starts the container.
-
#vnc_port ⇒ Integer
The port used by the container of vnc.
Constructor Details
#initialize(image = nil, capabilities: :firefox, headless: false, vnc_no_password: nil, vnc_password: nil, **kwargs) ⇒ SeleniumContainer
Initializes a new instance of SeleniumContainer
26 27 28 29 30 31 32 33 |
# File 'lib/testcontainers/selenium.rb', line 26 def initialize(image = nil, capabilities: :firefox, headless: false, vnc_no_password: nil, vnc_password: nil, **kwargs) image ||= SELENIUM_IMAGES[capabilities] super(image, **kwargs) @vnc_password = vnc_password @vnc_no_password = vnc_no_password @headless = headless @wait_for ||= add_wait_for(:logs, /Started Selenium/) end |
Instance Attribute Details
#headless ⇒ Object (readonly)
Returns the value of attribute headless.
19 20 21 |
# File 'lib/testcontainers/selenium.rb', line 19 def headless @headless end |
Instance Method Details
#port ⇒ Integer
Returns the port used by the container
45 46 47 |
# File 'lib/testcontainers/selenium.rb', line 45 def port SELENIUM_DEFAULT_PORT end |
#selenium_url(protocol: "http://") ⇒ String
Returns the selenium connection url (e.g host:port/wd/hub)
58 59 60 |
# File 'lib/testcontainers/selenium.rb', line 58 def selenium_url(protocol: "http://") "#{protocol}#{host}:#{mapped_port(port)}/wd/hub" end |
#start ⇒ SeleniumContainer
Starts the container
37 38 39 40 41 |
# File 'lib/testcontainers/selenium.rb', line 37 def start with_exposed_ports([port, vnc_port]) _configure super end |
#vnc_port ⇒ Integer
Returns the port used by the container of vnc.
50 51 52 |
# File 'lib/testcontainers/selenium.rb', line 50 def vnc_port VNC_DEFAULT_PORT end |