sketch of BrowserStack and Selenium testing setup
This commit is contained in:
52
script/selenium_test
Executable file
52
script/selenium_test
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
# script/selenium_test: Run selenium tests via BrowserStack
|
||||
|
||||
source "$(dirname "${0}")"/../script/include/global_header.inc.sh
|
||||
|
||||
export FLASK_ENV=selenium
|
||||
|
||||
# create upload directory for app
|
||||
mkdir uploads | true
|
||||
|
||||
# Fetch postgres settings and set them as ENV vars
|
||||
source ./script/get_db_settings
|
||||
|
||||
if [ -n "${PGDATABASE}" ]; then
|
||||
echo "Resetting database ${PGDATABASE}..."
|
||||
# Reset the db
|
||||
reset_db "${PGDATABASE}"
|
||||
else
|
||||
echo "ERROR: RESET_DB is set, but PGDATABASE is not!"
|
||||
echo "Skipping database reset..."
|
||||
fi
|
||||
|
||||
BSL_FILE=BrowserStackLocal
|
||||
if [[ `uname` == "Darwin" ]]; then
|
||||
BSL_DOWNLOAD="https://www.browserstack.com/browserstack-local/BrowserStackLocal-darwin-x64.zip"
|
||||
else
|
||||
BSL_DOWNLOAD="https://www.browserstack.com/browserstack-local/BrowserStackLocal-linux-x64.zip"
|
||||
fi
|
||||
|
||||
# Fetch BrowserStackLocal script
|
||||
if [ -e "${BSL_FILE}" ]; then
|
||||
echo "BrowserStack file already exists"
|
||||
else
|
||||
echo "downloading BrowserStack file"
|
||||
curl $BSL_DOWNLOAD --output $BSL_FILE.zip
|
||||
unzip $BSL_FILE.zip -d .
|
||||
rm $BSL_FILE.zip
|
||||
chmod u+x $BSL_FILE
|
||||
fi
|
||||
|
||||
# run BrowserStackLocal in the background
|
||||
echo "starting BrowserStack local client..."
|
||||
./$BSL_FILE --key $BROWSERSTACK_TOKEN &
|
||||
BSL_ID=$!
|
||||
|
||||
# run example selenium script that fetches the home page
|
||||
echo "running selenium example script"
|
||||
pipenv run python selenium_example.py
|
||||
|
||||
# kill BrowserStackLocal
|
||||
kill $BSL_ID
|
Reference in New Issue
Block a user