Skip to content

Commit

Permalink
test(integration): Install Chromedriver during dockerbuild (DefectDoj…
Browse files Browse the repository at this point in the history
…o#5283)

* test(integration): install chromedriver during dockerbuild

* fix(settings): Allow to copy .env* files to dockerfile
  • Loading branch information
alles-klar authored Oct 15, 2021
1 parent b2a76df commit afeeea0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.git
.gitignore
*.md
.env*
12 changes: 7 additions & 5 deletions Dockerfile.integration-tests
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ RUN \

RUN pip install --no-cache-dir selenium requests chromedriver-autoinstaller

# Installing Chromedriver
WORKDIR /opt/chrome-driver
RUN \
python -c "import chromedriver_autoinstaller; chromedriver_autoinstaller.install(cwd=True)" && \
chmod -R 0755 .
WORKDIR /app

COPY docker/wait-for-it.sh \
docker/entrypoint-integration-tests.sh \
/
Expand All @@ -38,11 +45,6 @@ COPY tests/ ./tests/

RUN chmod -R 0777 /app

# These 2 lines are needed for the chromium driver
RUN chmod -R ugo+w /usr/local/lib/python3.8/site-packages
RUN mkdir /.local
RUN chmod -R ugo+w /.local

USER 1001
ENV \
DD_ADMIN_USER=admin \
Expand Down
1 change: 1 addition & 0 deletions docker/entrypoint-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ if [ $COUNTER -gt 10 ]; then
exit 1
fi

export CHROMEDRIVER=$(find /opt/chrome-driver -name chromedriver)

# Run available unittests with a simple setup
# All available Integrationtest Scripts are activated below
Expand Down
5 changes: 1 addition & 4 deletions tests/base_test_class.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from selenium import webdriver
import chromedriver_autoinstaller
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Expand Down Expand Up @@ -50,8 +49,6 @@ class BaseTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):

chromedriver_autoinstaller.install()

# Path for automatic downloads, mapped to the media path
cls.export_path = 'media'

Expand Down Expand Up @@ -88,7 +85,7 @@ def setUpClass(cls):

# change path of chromedriver according to which directory you have chromedriver.
print('starting chromedriver with options: ', vars(dd_driver_options), desired)
dd_driver = webdriver.Chrome('chromedriver', chrome_options=dd_driver_options, desired_capabilities=desired)
dd_driver = webdriver.Chrome(os.environ['CHROMEDRIVER'], chrome_options=dd_driver_options, desired_capabilities=desired)
# best practice is only use explicit waits
dd_driver.implicitly_wait(1)

Expand Down

0 comments on commit afeeea0

Please sign in to comment.