Commit 8477faeb authored by Carsten  Rose's avatar Carsten Rose

Merge branch 'selenium_marcel' into 'master'

Selenium marcel

See merge request !218
parents 8a64f2fb 44a67188
Pipeline #2849 passed with stages
in 3 minutes and 26 seconds
......@@ -20,6 +20,9 @@ For the below scripts to work please name the images ```python-selenium``` and `
## Run qfq in docker container from scratch
1. clone qfq git project
```git clone https://git.math.uzh.ch/typo3/qfq```
2. change to project directory (qfq)
3. ```make bootstrap```
4. ``` cd docker```
......@@ -53,6 +56,7 @@ Assumes you have run qfq in docker as explained above.
Assumes you have run qfq in docker as explained above.
0. Install selenium for python: ```python3 -m pip install --user selenium```
1. again from the docker directory run ```./run_selenium_tests_local.sh```
## Run a single selenium test file on local machine
......@@ -88,4 +92,4 @@ Assumes you have run qfq in docker as explained above.
```unzip /tmp/chromedriver.zip chromedriver```
3. export chromedriver path environment variable before running selenium tests locally
```export CHROMEDRIVER_PATH=<absolute path to chromedriver>/chromedriver```
\ No newline at end of file
```export CHROMEDRIVER_PATH=<absolute path to chromedriver>/chromedriver```
This diff is collapsed.
This diff is collapsed.
#!/bin/bash -ex
source run_qfq_docker.output
MYSQL_ROOT_PASSWORD=crazyfish123
MYSQL_ROOT_PASSWORD=MN7HKEB7AnvdVKQE
# qfq database dump
mysqldump -u root --password=${MYSQL_ROOT_PASSWORD} --port=${DB_PORT} -h 127.0.0.1 qfq_db > db_fixture_qfq.sql
......
......@@ -73,7 +73,7 @@ until mysql -u root --password=${MYSQL_ROOT_PASSWORD} --port=${DB_PORT} -h 127.0
-e "CREATE DATABASE ${T3_DATABASE}; CREATE DATABASE ${QFQ_DATABASE}"
do
tries=$((tries+1))
if [[ "${tries}" -gt 30 ]]; then
if [[ "${tries}" -gt 60 ]]; then
echo "Timeout: could not connect to database."
exit 1;
fi
......
#!/bin/bash -ex
#!/bin/bash
source run_qfq_docker.output
# download chromedriver
if [ ! -f chromedriver ]; then
wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip
unzip /tmp/chromedriver.zip chromedriver
chmod +x chromedriver
# this function prints a separator
function print_separator {
# prints the separator
echo -e "----------------------------------------------------------------------"
}
# prints the starting separator
print_separator
# checks that a file named geckodriver doesn't already exist
if [ ! -f "geckodriver" ]; then
# stores the current version of the driver
gecko_version=$(curl --silent "https://api.github.com/repos/mozilla/geckodriver/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")') &> /dev/null
# downloads the geckodriver from github
wget -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/${gecko_version}/geckodriver-${gecko_version}-linux64.tar.gz &> /dev/null
# unzips the downloaded geckodriver
tar xzf /tmp/geckodriver.tar.gz geckodriver &> /dev/null
# makes the geckodriver executable
chmod +x geckodriver &> /dev/null
# prints a success output
echo -e "Successfully downloaded geckodriver"
fi
# checks that a file named chromedriver doesn't already exist
if [ ! -f "chromedriver" ]; then
# downloads the newest version of the chromedriver from google
wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip &> /dev/null
# unzips the downloaded chromedriver
unzip /tmp/chromedriver.zip chromedriver &> /dev/null
# makes the chromedriver executable
chmod +x chromedriver &> /dev/null
# prints a success output
echo -e "Successfully downloaded chromedriver"
fi
# reads the url to test from the input variable
SELENIUM_URL=$1
# checks if the selenium url is not given
if [ -z $SELENIUM_URL ]; then
SELENIUM_URL="http://127.0.0.1:${T3_PORT}"
fi
# defines the url to be used during testing
export SELENIUM_URL=$SELENIUM_URL
# stores the default engine
DEFAULT_ENGINE="chrome"
# reads the engine from the 2nd input variable
ENGINE=$2
# checks if an engine is not specified
if [ -z $ENGINE ]; then
# defines the default engine to use during tests
export BROWSER=$DEFAULT_ENGINE
# defines the path to the drivers of the engine
export DRIVER_PATH="${PWD}/${DEFAULT_ENGINE}driver"
else
# defines the engine to use during tests
export BROWSER=$ENGINE
# defines the path to the drivers of the engine
export DRIVER_PATH="${PWD}/${ENGINE}driver"
fi
# stores the default headless option
DEFAULT_HEADLESS="no"
# reads the headless option from the 3rd input variable
HEADLESS=$3
# checks if the headless parameter is not specified
if [ -z $HEADLESS ]; then
# defines if the browser gui should open
export SELENIUM_HEADLESS=$DEFAULT_HEADLESS
else
# defines if the browser gui should open
export SELENIUM_HEADLESS=$HEADLESS
fi
# stores the default slowdown
DEFAULT_SLOWDOWN="0"
# reads the slowdown from the 4th input variable
SLOWDOWN=$4
# checks if the slowdown parameter is not specified
if [ -z $SLOWDOWN ]; then
# defines what slowdown should be applied
export SELENIUM_SLOWDOWN=$DEFAULT_SLOWDOWN
else
# defines what slowdown should be applied
export SELENIUM_SLOWDOWN=$SLOWDOWN
fi
export CHROMEDRIVER_PATH="${PWD}/chromedriver"
# run tests
cd ../extension/Tests/selenium
export SELENIUM_URL="http://127.0.0.1:${T3_PORT}"
export SELENIUM_HEADLESS="no"
python -m unittest discover
\ No newline at end of file
# prints running tests
echo -e -n "Running tests: "
# runs the python tests
python3 -W ignore -m unittest discover
# checks if the tests were successful
if [ $? -eq 0 ]; then
print_separator
# prints a success message
echo -e "Successfully tested ${SELENIUM_URL}"
else
print_separator
# prints a success message
echo -e "Failed while testing ${SELENIUM_URL}"
fi
# prints the trailing separator
print_separator
# exits the program
exit 0
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment