Move waiting for Selenium docker instances into ruby code

This commit is contained in:
Thomas Walpole 2018-06-28 10:18:50 -07:00
parent a8fdf19421
commit 3ecc48b93d
4 changed files with 33 additions and 27 deletions

View File

@ -95,21 +95,11 @@ before_script:
awesome &
fi
- if [[ $CAPYBARA_REMOTE = true ]]; then
docker-compose up -d
TIMEOUT=20
until wget --spider http://localhost:4444 > /dev/null 2>&1 || [ $TIMEOUT -eq 0 ]; do
echo "Waiting for selenium server, $((TIMEOUT--)) remaining attempts...";
sleep 1;
done
TIMEOUT=20
until wget --spider http://localhost:4445 > /dev/null 2>&1 || [ $TIMEOUT -eq 0 ]; do
echo "Waiting for selenium server, $((TIMEOUT--)) remaining attempts...";
sleep 1;
done
if [[ $CAPYBARA_FF = true ]]; then
docker-compose up -d selenium_firefox;
else
docker-compose up -d selenium_chrome;
fi;
fi
script: "bundle exec rake travis"

View File

@ -1,6 +1,4 @@
---
version: "3"
services:
selenium_chrome:
network_mode: "host"

View File

@ -14,11 +14,20 @@ def selenium_port
end
def ensure_selenium_running!
TCPSocket.open(selenium_host, selenium_port)
rescue
raise 'Selenium is not running. ' \
"You can run a selenium server easily with: \n" \
' $ docker-compose up -d selenium_chrome'
timer = Capybara::Helpers.timer(expire_in: 20)
begin
TCPSocket.open(selenium_host, selenium_port)
rescue
if timer.expired?
raise 'Selenium is not running. ' \
"You can run a selenium server easily with: \n" \
' $ docker-compose up -d selenium_chrome'
else
puts "Waiting for Selenium docker instance..."
sleep 1
retry
end
end
end
Capybara.register_driver :selenium_chrome_remote do |app|

View File

@ -14,11 +14,20 @@ def selenium_port
end
def ensure_selenium_running!
TCPSocket.open(selenium_host, selenium_port)
rescue
raise 'Selenium is not running. ' \
"You can run a selenium server easily with: \n" \
' $ docker-compose up -d selenium_firefox'
timer = Capybara::Helpers.timer(expire_in: 20)
begin
TCPSocket.open(selenium_host, selenium_port)
rescue
if timer.expired?
raise 'Selenium is not running. ' \
"You can run a selenium server easily with: \n" \
' $ docker-compose up -d selenium_firefox'
else
puts "Waiting for Selenium docker instance..."
sleep 1
retry
end
end
end
Capybara.register_driver :selenium_firefox_remote do |app|