Zalenium Dockerized Selenium Grid

Zalenium provides docker images (Hub + Nodes) with the latest browser drivers, browsers, and tools (for any language bindings) required for Selenium automation. The containers created from these images can be scaled-up with simple CLI commands. By default, there will be two live containers up and running.

  • Open terminal and download the below images from Docker hub
docker pull elgalu/selenium
docker pull dosel/zalenium
  • Create docker containers and start Zalenium proxy in a single command
docker run --rm -ti --name zalenium -p 4444:4444 -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/videos:/home/seluser/videos --privileged dosel/zalenium start
  • Now, configure the driver initialization
options = {
  'chromeOptions' => {
    'args' => ['disable-infobars', 'disable-gpu', 'privileged', 'ignore-certificate-errors']
  }
}

caps = Selenium::WebDriver::Remote::Capabilities.chrome(options)
@driver = Selenium::WebDriver.for :remote, :url => "http://0.0.0.0:4444/wd/hub", desired_capabilities: caps
  • Check out live test session using the below URL
http://localhost:4444/grid/admin/live

  • Start monitoring the Zalenium live interface once the tests were triggered

  • You can also review tests through the recorded video stream
http://localhost:4444/dashboard/

  • To stop the docker containers spun through Zalenium, simply exit Zalenium proxy using the below command
docker stop zalenium

 

Method #2 (most preferred approach)

Using this approach actually detaches the Zalenium process from running in the terminal

  • A single line command to start Zalenium proxy and make docker containers up
curl -sSL https://raw.githubusercontent.com/dosel/t/i/p | bash -s start
  • Command to terminate the Zalenium proxy along with the running/exited containers
curl -sSL https://raw.githubusercontent.com/dosel/t/i/p | bash -s stop
  • Scale up docker containers as desired; but, make sure you create replicas only if the machine has proper CPU (x4/x8/x16) cores specific to the containers
curl -sSL https://raw.githubusercontent.com/dosel/t/i/p | bash -s start --desiredContainers 8 --screenWidth 1440 --screenHeight 900 --timeZone "Asia/Dubai" --maxDockerSeleniumContainers 10 --maxTestSessions 30 --videoRecordingEnabled true
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s