OpenStack in a snap!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.5KB

  1. #!/usr/bin/env python
  2. """
  3. test_horizonlogin.py
  4. This is a basic test of Horizon functionality. We verify that:
  5. 1) Horizon is running, and we can hit the landing page.
  6. 2) We can login successfully.
  7. This is based on code generated by the Selinum Web IDE.
  8. """
  9. import os
  10. import socket
  11. import unittest
  12. import xvfbwrapper
  13. from selenium import webdriver
  14. from selenium.webdriver.common.by import By
  15. HORIZON_IP = os.environ.get("HORIZON_IP", "10.20.20.1")
  16. class TestHorizonlogin(unittest.TestCase):
  17. def setUp(self):
  18. self.display = xvfbwrapper.Xvfb(width=1280, height=720)
  19. self.display.start()
  20. self.driver = webdriver.PhantomJS()
  21. def tearDown(self):
  22. self.driver.quit()
  23. self.display.stop()
  24. def test_horizonlogin(self):
  25. self.driver.get("http://{horizon_ip}/".format(horizon_ip=HORIZON_IP))
  26. # Login to horizon!
  27. self.driver.find_element(By.ID, "id_username").click()
  28. self.driver.find_element(By.ID, "id_username").send_keys("admin")
  29. self.driver.find_element(By.ID, "id_password").send_keys("keystone")
  30. self.driver.find_element(By.CSS_SELECTOR, "#loginBtn > span").click()
  31. # Verify that we can click something on the dashboard -- e.g.,
  32. # we're still not sitting at the login screen.
  33. self.driver.find_element(By.LINK_TEXT, "Images").click()
  34. if __name__ == '__main__':
  35. # Run our tests, ignorning deprecation warnings and warnings about
  36. # unclosed sockets. (TODO: setup a selenium server so that we can
  37. # move from PhantomJS, which is deprecated, to to Selenium headless.)
  38. unittest.main(warnings='ignore')