Don't merge -- minimal test to verify selenium!

Change-Id: I3f4b6f962d5ace3717f2ec213e39fcd9ca29eaf6
This commit is contained in:
Pete Vander Giessen 2019-09-13 20:48:58 +00:00
parent df629589c3
commit 3e7a1ee223
4 changed files with 19 additions and 32 deletions

Binary file not shown.

View File

@ -11,40 +11,32 @@ This is based on code generated by the Selinum Web IDE.
"""
import socket
import os
import unittest
import time
import xvfbwrapper
from selenium import webdriver
from selenium.webdriver.common.by import By
DRIVER_PATH = os.sep.join([
os.path.dirname(os.path.realpath(__file__)),
"phantomjs",
])
class TestHorizonlogin(unittest.TestCase):
def setUp(self):
socket.setdefaulttimeout(60)
time.sleep(1)
self.display = xvfbwrapper.Xvfb(width=1280, height=720)
self.display.start()
self.driver = webdriver.PhantomJS(executable_path=DRIVER_PATH)
self.driver = webdriver.PhantomJS()
def tearDown(self):
self.driver.quit()
self.display.stop()
def test_horizonlogin(self):
self.driver.get("http://10.20.20.1/")
# Login to horizon!
self.driver.find_element(By.ID, "id_username").click()
self.driver.find_element(By.ID, "id_username").send_keys("admin")
self.driver.find_element(By.ID, "id_password").send_keys("keystone")
self.driver.find_element(By.CSS_SELECTOR, "#loginBtn > span").click()
# Verify that we can click something on the dashboard -- e.g.,
# we're still not sitting at the login screen.
self.driver.find_element(By.LINK_TEXT, "Images").click()
self.driver.get("http://petevg.com/")
self.driver.find_element(By.ID, "post-17").click()
if __name__ == '__main__':
# Run our tests, ignorning deprecation warnings and warnings about
# unclosed sockets. (TODO: setup a selenium server so that we can
# move from PhantomJS, which is deprecated, to to Selenium headless.)
unittest.main(warnings='ignore')
# Run our tests, ignorning deprecation warnings and warnings about
# unclosed sockets. (TODO: setup a selenium server so that we can
# move from PhantomJS, which is deprecated, to to Selenium headless.)
unittest.main(warnings='ignore')

View File

@ -5,13 +5,7 @@ set -ex
export PATH=/snap/bin:$PATH
sudo apt update
sudo apt install -y snapd
# Also install the X virtual framebuffer, which is required for
# selenium tests of the horizon dashboard.
sudo apt install -y xvfb
sudo apt install -y xvfb phantomjs
sudo snap install --classic snapcraft
sudo snap install --classic lxd
sudo lxd init --auto
sudo snapcraft --use-lxd

11
tox.ini
View File

@ -7,19 +7,20 @@ basepython=python3
install_command = pip install {opts} {packages}
setenv =
PATH = /snap/bin:{env:PATH}
passenv = HOME TERM DISPLAY
passenv = HOME TERM
whitelist_externals =
sudo
/snap/bin/snapcraft
[testenv:snap]
# Testing environment for the gerrit gate. Named 'snap' to conform to
# the requirements of the snap friendly job that we inherit from in
# .zuul.yaml.
# Run browser tests. Assumes that you have the snap installed and
# initialized locally, and a valid DISPLAY (install xvfb for a virtual
# one).
# TODO: figure out how to integrate this w/ multipass. (e.g. setup
# port forwarding and call into the mulitpass machine.)
deps = -r{toxinidir}/test-requirements.txt
commands =
{toxinidir}/tools/lxd_build.sh
{toxinidir}/tests/basic-test.sh
{toxinidir}/tests/test_horizonlogin.py
[testenv:multipass]