From 736a4de0f0099b72217de30754a9153202ef701b Mon Sep 17 00:00:00 2001 From: Tessa Alexander <1619343+asset-web@users.noreply.github.com> Date: Tue, 24 Oct 2023 21:37:44 +0100 Subject: [PATCH] Bug fix testing env (#235) * Expand GitHub actions environment * Bug fix the path to chromedriver * Only install the chrome driver if google chrome is installed. * Debug tests/build-test-env.sh installing Chrome --- deploy/fabfile.py | 28 +++++++++++++++------------- tests/base_selenium_test_case.py | 2 +- tests/build-test-env.sh | 8 ++++++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/deploy/fabfile.py b/deploy/fabfile.py index c10df439..103934aa 100644 --- a/deploy/fabfile.py +++ b/deploy/fabfile.py @@ -143,19 +143,21 @@ def make_virtualenv(env="dev", configure_apache=False, clone_repo=False, branch= # Install local copy of the chromedriver if env in ("dev", "test",): - with change_dir(venv_dir + "/bin"): - # Download the correct chrome driver version for the version of google chrome that is currently installed, - # ref: https://sites.google.com/a/chromium.org/chromedriver/downloads/version-selection#:~:text=Each%20version%20of%20ChromeDriver%20supports,3683. - google_chrome_version = caller('google-chrome --version').strip("Google Chrome ") - chrome_driver_version = google_chrome_version[:google_chrome_version.rindex(".")] - version = urllib2.urlopen('https://chromedriver.storage.googleapis.com/LATEST_RELEASE_'+chrome_driver_version).read() - caller('wget https://chromedriver.storage.googleapis.com/' + version + '/chromedriver_linux64.zip') - caller('ls -l') - caller('rm -f chromedriver') - caller('unzip -o chromedriver_linux64.zip') - caller('ls -l') - caller('rm chromedriver_linux64.zip*') - caller('ls -l') + with change_dir(venv_dir + "/bin"): + # Only install the chrome driver if google chrome is installed. + if caller('which google-chrome'): + # Download the correct chrome driver version for the version of google chrome that is currently installed, + # ref: https://sites.google.com/a/chromium.org/chromedriver/downloads/version-selection#:~:text=Each%20version%20of%20ChromeDriver%20supports,3683. + google_chrome_version = caller('google-chrome --version').strip("Google Chrome ") + chrome_driver_version = google_chrome_version[:google_chrome_version.rindex(".")] + version = urllib2.urlopen('https://chromedriver.storage.googleapis.com/LATEST_RELEASE_'+chrome_driver_version).read() + caller('wget https://chromedriver.storage.googleapis.com/' + version + '/chromedriver_linux64.zip') + caller('ls -l') + caller('rm -f chromedriver') + caller('unzip -o chromedriver_linux64.zip') + caller('ls -l') + caller('rm chromedriver_linux64.zip*') + caller('ls -l') def deploy(env="dev", branch="master", using_apache=True, migrate_db=True, use_local_mode=False, use_pip_sync=False, requirements="requirements", project_dir=PROJECT_ROOT): diff --git a/tests/base_selenium_test_case.py b/tests/base_selenium_test_case.py index 09d800cd..a9ba8c90 100644 --- a/tests/base_selenium_test_case.py +++ b/tests/base_selenium_test_case.py @@ -30,7 +30,7 @@ def setUpClass(cls): cls.display = Display(visible=0, size=(1920, 1080)) cls.display.start() # ref: https://github.com/SeleniumHQ/selenium/issues/12746 - service = webdriver.ChromeService(executable_path="../../../bin/chromedriver") + service = webdriver.ChromeService(executable_path=settings.BASE_DIR + "/../../../bin/chromedriver") cls.driver = webdriver.Chrome(service=service) cls.driver.implicitly_wait(10) diff --git a/tests/build-test-env.sh b/tests/build-test-env.sh index 5d3daed0..58a78e5c 100644 --- a/tests/build-test-env.sh +++ b/tests/build-test-env.sh @@ -37,10 +37,14 @@ sudo apt-get install -y python3-wheel-whl echo "Set up alias for python3.8" which python3 -# which python3.8 -# alias python3.8="python3" which python3.8 +# Install Chrome +wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb +sudo apt-get install -y ./google-chrome-stable_current_amd64.deb +which google-chrome +google-chrome --version + cd $GITHUB_WORKSPACE cd lib/test/src/temmpo