Commit 5b4fb2f9 authored by Marc Egger's avatar Marc Egger

fix selenium tests, remove chromedriver from npm

parent d5b7d0fe
......@@ -9,7 +9,7 @@ variables:
stages:
- before
- build
# - selenium
- selenium
documentation:
stage: before
......@@ -48,29 +48,30 @@ release:
- scp qfq_${VERSION}_*.zip w16:qfq/releases/
- mv qfq_${VERSION}_*.zip build/qfq.zip
# selenium:
# stage: selenium
# script:
# - unzip -q build/qfq.zip -d qfq
# - cd docker/
# - ./run_qfq_docker.sh -no-deploy
# - ./deploy_to_container.sh ../qfq
# - ./run_selenium_tests_docker.sh
# - echo "hello"
# after_script:
# # remove containers and move logs to persistent location
# - cd docker; ./remove-containers.sh <<< "y"
# - cd ..
# - umask 002
# - mkdir "$SELENIUM_LOGS_PATH/$CI_COMMIT_SHORT_SHA"
# - cp extension/Tests/selenium/selenium_logs/* "$SELENIUM_LOGS_PATH/$CI_COMMIT_SHORT_SHA/"
# - echo "Selenium Logs copied to $SELENIUM_LOGS_PATH/$CI_COMMIT_SHORT_SHA/"
# - echo "Or download result (log/screenshot) in gitlab under CI/CD > Pipelines <job> > right side 'Artifacts'"
selenium:
stage: selenium
script:
- unzip -q build/qfq.zip -d qfq
- cd docker/
- ./run_qfq_docker.sh -no-deploy
- ./deploy_to_container.sh ../qfq
- ./run_selenium_tests_docker.sh
- echo "hello"
after_script:
# remove containers and move logs to persistent location
- cd docker; ./remove-containers.sh <<< "y"
- cd ..
- umask 002
- mkdir "$SELENIUM_LOGS_PATH/$CI_COMMIT_SHORT_SHA"
- cp extension/Tests/selenium/selenium_logs/* "$SELENIUM_LOGS_PATH/$CI_COMMIT_SHORT_SHA/"
- echo "Selenium Logs copied to $SELENIUM_LOGS_PATH/$CI_COMMIT_SHORT_SHA/"
- echo "Or download result (log/screenshot) in gitlab under CI/CD > Pipelines <job> > right side 'Artifacts'"
# artifacts:
# expire_in: 1 week
# paths:
# - extension/Tests/selenium/selenium_logs/
artifacts:
expire_in: 1 week
when: on_failure
paths:
- extension/Tests/selenium/selenium_logs/
This diff is collapsed.
This diff is collapsed.
......@@ -56,14 +56,14 @@ 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
export SELENIUM_BROWSER=$DEFAULT_ENGINE
# defines the path to the drivers of the engine
export DRIVER_PATH="${PWD}/${DEFAULT_ENGINE}driver"
export SELENIUM_DRIVER_PATH="${PWD}/${DEFAULT_ENGINE}driver"
else
# defines the engine to use during tests
export BROWSER=$ENGINE
export SELENIUM_BROWSER=$ENGINE
# defines the path to the drivers of the engine
export DRIVER_PATH="${PWD}/${ENGINE}driver"
export SELENIUM_DRIVER_PATH="${PWD}/${ENGINE}driver"
fi
# stores the default headless option
......
......@@ -43,12 +43,8 @@ class QfqSeleniumTestCase(unittest.TestCase):
chrome_driver_path = "chromedriver"
# these variables can be overwritten by environment variables of the same name
BROWSER = chrome_browser_name
DRIVER_PATH = ""
if BROWSER == chrome_browser_name:
DRIVER_PATH = chrome_driver_path
elif BROWSER == gecko_browser_name:
DRIVER_PATH = gecko_driver_path
SELENIUM_BROWSER = chrome_browser_name
SELENIUM_DRIVER_PATH = ""
SELENIUM_LOGS_PATH = os.getcwd()
SELENIUM_HEADLESS = 'yes' # set environment variable to 'no' to turn off
SELENIUM_URL = urlFromHostname('typo3container')
......@@ -61,13 +57,19 @@ class QfqSeleniumTestCase(unittest.TestCase):
"""
# reads the environment variables
cls.BROWSER = os.environ.get('BROWSER', cls.BROWSER)
cls.DRIVER_PATH = os.environ.get('DRIVER_PATH', cls.DRIVER_PATH)
cls.SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', cls.SELENIUM_BROWSER)
cls.SELENIUM_DRIVER_PATH = os.environ.get('SELENIUM_DRIVER_PATH', cls.SELENIUM_DRIVER_PATH)
cls.SELENIUM_LOGS_PATH = os.environ.get('SELENIUM_LOGS_PATH', cls.SELENIUM_LOGS_PATH)
cls.SELENIUM_HEADLESS = os.environ.get('SELENIUM_HEADLESS', cls.SELENIUM_HEADLESS)
cls.SELENIUM_URL = os.environ.get('SELENIUM_URL', cls.SELENIUM_URL)
cls.SELENIUM_SLOWDOWN = float(os.environ.get('SELENIUM_SLOWDOWN', cls.SELENIUM_SLOWDOWN))
# set browser path
if cls.SELENIUM_BROWSER == cls.chrome_browser_name:
cls.SELENIUM_DRIVER_PATH = cls.chrome_driver_path
elif cls.SELENIUM_BROWSER == cls.gecko_browser_name:
cls.SELENIUM_DRIVER_PATH = cls.gecko_driver_path
# setup log directory, delete very old log files
cls.selenium_logs_dir = 'selenium_logs'
cls.selenium_logs_dir_path = os.path.join(cls.SELENIUM_LOGS_PATH, cls.selenium_logs_dir)
......@@ -85,7 +87,7 @@ class QfqSeleniumTestCase(unittest.TestCase):
os.remove(file_path)
# initializes webdriver
if cls.BROWSER == cls.chrome_browser_name:
if cls.SELENIUM_BROWSER == cls.chrome_browser_name:
chrome_options = Options()
if cls.SELENIUM_HEADLESS != 'no':
chrome_options.add_argument("--headless")
......@@ -94,16 +96,16 @@ class QfqSeleniumTestCase(unittest.TestCase):
chrome_options.add_argument("--no-sandbox")
desired_capabilities = {'UNEXPECTED_ALERT_BEHAVIOUR': 'ignore'}
cls.driver = webdriver.Chrome(chrome_options=chrome_options,
executable_path=cls.DRIVER_PATH,
executable_path=cls.SELENIUM_DRIVER_PATH,
desired_capabilities=desired_capabilities)
elif cls.BROWSER == cls.gecko_browser_name:
elif cls.SELENIUM_BROWSER == cls.gecko_browser_name:
firefox_options = FFOptions()
if cls.SELENIUM_HEADLESS != 'no':
firefox_options.headless = True
desired_capabilities = webdriver.DesiredCapabilities().FIREFOX
cls.driver = webdriver.Firefox(firefox_options=firefox_options,
executable_path=cls.DRIVER_PATH,
executable_path=cls.SELENIUM_DRIVER_PATH,
capabilities=desired_capabilities)
cls.driver.set_window_size(1920, 1080)
......
......@@ -412,6 +412,8 @@ class TestBasicFunctionality(qfqselenium.QfqSeleniumTestCase):
# uploads the file
s.qfq_upload_file(s.file_upload_ref, unique_file_name, "txt", 32)
s.qfq_wait(1)
# clicks the save button to save the data
s.qfq_click_save_form_button()
# clicks the close button to return to the list of data entries
......
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