From f61cbbf72fa0432fc9b1c228169ac83a449867cd Mon Sep 17 00:00:00 2001 From: Dmitrii Shcherbakov Date: Thu, 23 Apr 2020 15:55:12 +0300 Subject: [PATCH] Switch to Firefox from PhantomJS As PhantomJS is no longer maintained and there are packaging problems, let's switch to using Firefox in a headless configuration which is a scenario supported by Selenium. Change-Id: Ic98c5b71202f033b9013c126f6bacdb49980acfa --- tests/framework.py | 9 ++++----- tools/basic_setup.sh | 11 +++-------- tools/lxd_build.sh | 9 ++------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/tests/framework.py b/tests/framework.py index b0f1617..07aef6f 100644 --- a/tests/framework.py +++ b/tests/framework.py @@ -4,11 +4,11 @@ import unittest import os import subprocess import time -import xvfbwrapper from typing import List import petname from selenium import webdriver +from selenium.webdriver.firefox.options import Options as FirefoxOptions from selenium.webdriver.common.by import By @@ -58,9 +58,9 @@ def gui_wrapper(func): def wrapper(cls, *args, **kwargs): # Setup Selenium Driver - cls.display = xvfbwrapper.Xvfb(width=1280, height=720) - cls.display.start() - cls.driver = webdriver.PhantomJS() + options = FirefoxOptions() + options.add_argument("-headless") + cls.driver = webdriver.Firefox(options=options) # Run function try: @@ -69,7 +69,6 @@ def gui_wrapper(func): finally: # Tear down driver cls.driver.quit() - cls.display.stop() return wrapper diff --git a/tools/basic_setup.sh b/tools/basic_setup.sh index e4355ad..3a8177c 100755 --- a/tools/basic_setup.sh +++ b/tools/basic_setup.sh @@ -2,11 +2,6 @@ set -ex -#sudo apt update - -# Install the X virtual framebuffer, which is required for selenium -# tests of the horizon dashboard. -sudo apt install -y xvfb npm libfontconfig1 -phantomjs -v || sudo npm install -g phantomjs-prebuilt -# Verify that PhantomJS, our selenium web driver, works. -phantomjs -v +sudo apt update +# install Firefox which will be used for Web UI testing in a headless mode. +sudo apt install -y firefox-geckodriver python3-petname python3-selenium diff --git a/tools/lxd_build.sh b/tools/lxd_build.sh index 5731a94..da8480a 100755 --- a/tools/lxd_build.sh +++ b/tools/lxd_build.sh @@ -5,13 +5,8 @@ set -ex export PATH=/snap/bin:$PATH sudo apt update - -# Install the X virtual framebuffer, which is required for selenium -# tests of the horizon dashboard. -sudo apt install -y xvfb npm libfontconfig1 -sudo npm install -g phantomjs-prebuilt -# Verify that PhantomJS, our selenium web driver, works. -phantomjs -v +# install Firefox which will be used for Web UI testing in a headless mode. +sudo apt install -y firefox-geckodriver python3-petname python3-selenium # Setup snapd and snapcraft sudo apt install -y snapd