Shell script to start local zalenium
#!/bin/bash
# Prerequsites:
# Docker is intalled and can be ran without sudo:
# sudo usermod -aG docker <name-of-user-to-grant-permission>
# newgrp docker
# docker run hello-world
# Add to Intellij:
# Open maven runner for Zalenium
# Under parameters, add 'Before launch: External tool, ...'
# Name: Start Zalanium
# Program: /bin/sh
# Arguments: zalenium.sh
# Working directory: <path-to-folder>
# live preview at http://localhost:4444/grid/admin/live
# Use `docker stop zalenium` to kill the container
if [ $(curl -sSL http://localhost:4444/wd/hub/status | jq .value.ready | grep true) == true ]; then
echo 'Zalenium is already running'
else
echo 'Zalenium is not running, standing up Zalenium...'
docker pull elgalu/selenium
docker pull dosel/zalenium
docker run --rm -ti -d --name zalenium -p 4444:4444 -e ZALENIUM_SELENIUM_CONTAINER_CPU_LIMIT=1000000000 -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/videos:/home/seluser/videos --privileged dosel/zalenium start --screenWidth 1920 --screenHeight 1480 --timeZone "Australia/Brisbane" --videoRecordingEnabled false
COUNTER=0
until [ $COUNTER -eq 10 ]; do
echo 'Waiting for Zalenium to start...'
sleep 5
let COUNTER+=1
if [ $(curl -sSL http://localhost:4444/wd/hub/status | jq .value.ready | grep true) == true ]; then
echo 'zalenium is now running'
break
fi
if [ $COUNTER -eq 10 ]; then
echo 'Gave up waiting for Zalenium to start after ' $COUNTER ' attempts.'
fi
done
fi