microstack/tests/test_horizonlogin.py

48 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python
"""
test_horizonlogin.py
This is a basic test of Horizon functionality. We verify that:
1) Horizon is running, and we can hit the landing page.
2) We can login successfully.
This is based on code generated by the Selinum Web IDE.
"""
import os
import socket
import unittest
import xvfbwrapper
from selenium import webdriver
from selenium.webdriver.common.by import By
class TestHorizonlogin(unittest.TestCase):
def setUp(self):
self.display = xvfbwrapper.Xvfb(width=1280, height=720)
self.display.start()
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()
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')