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
This commit is contained in:
Dmitrii Shcherbakov 2020-04-23 15:55:12 +03:00
parent 214f0e8d5b
commit f61cbbf72f
3 changed files with 9 additions and 20 deletions

View File

@ -4,11 +4,11 @@ import unittest
import os import os
import subprocess import subprocess
import time import time
import xvfbwrapper
from typing import List from typing import List
import petname import petname
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
@ -58,9 +58,9 @@ def gui_wrapper(func):
def wrapper(cls, *args, **kwargs): def wrapper(cls, *args, **kwargs):
# Setup Selenium Driver # Setup Selenium Driver
cls.display = xvfbwrapper.Xvfb(width=1280, height=720) options = FirefoxOptions()
cls.display.start() options.add_argument("-headless")
cls.driver = webdriver.PhantomJS() cls.driver = webdriver.Firefox(options=options)
# Run function # Run function
try: try:
@ -69,7 +69,6 @@ def gui_wrapper(func):
finally: finally:
# Tear down driver # Tear down driver
cls.driver.quit() cls.driver.quit()
cls.display.stop()
return wrapper return wrapper

View File

@ -2,11 +2,6 @@
set -ex set -ex
#sudo apt update sudo apt update
# install Firefox which will be used for Web UI testing in a headless mode.
# Install the X virtual framebuffer, which is required for selenium sudo apt install -y firefox-geckodriver python3-petname python3-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

View File

@ -5,13 +5,8 @@ set -ex
export PATH=/snap/bin:$PATH export PATH=/snap/bin:$PATH
sudo apt update sudo apt update
# install Firefox which will be used for Web UI testing in a headless mode.
# Install the X virtual framebuffer, which is required for selenium sudo apt install -y firefox-geckodriver python3-petname python3-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
# Setup snapd and snapcraft # Setup snapd and snapcraft
sudo apt install -y snapd sudo apt install -y snapd