mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Move waiting for Selenium docker instances into ruby code
This commit is contained in:
parent
a8fdf19421
commit
3ecc48b93d
4 changed files with 33 additions and 27 deletions
20
.travis.yml
20
.travis.yml
|
@ -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"
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
---
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
selenium_chrome:
|
||||
network_mode: "host"
|
||||
|
|
|
@ -14,11 +14,20 @@ def selenium_port
|
|||
end
|
||||
|
||||
def ensure_selenium_running!
|
||||
timer = Capybara::Helpers.timer(expire_in: 20)
|
||||
begin
|
||||
TCPSocket.open(selenium_host, selenium_port)
|
||||
rescue
|
||||
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|
|
||||
|
|
|
@ -14,11 +14,20 @@ def selenium_port
|
|||
end
|
||||
|
||||
def ensure_selenium_running!
|
||||
timer = Capybara::Helpers.timer(expire_in: 20)
|
||||
begin
|
||||
TCPSocket.open(selenium_host, selenium_port)
|
||||
rescue
|
||||
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|
|
||||
|
|
Loading…
Reference in a new issue