| 1 |
import unittest |
| 2 |
|
| 3 |
from selenium import webdriver |
| 4 |
from selenium.webdriver.chrome.service import Service |
| 5 |
from selenium.webdriver.support.wait import WebDriverWait |
| 6 |
from selenium.webdriver.common.by import By |
| 7 |
from selenium.webdriver.support.ui import Select |
| 8 |
import os |
| 9 |
import sys |
| 10 |
|
| 11 |
class TestDmarcSrgWeb(unittest.TestCase): |
| 12 |
|
| 13 |
def setUp(self): |
| 14 |
self.data_dir = os.getenv('AUTOPKGTEST_TMP', default='/tmp') + '/google-chrome' |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
options = webdriver.ChromeOptions() |
| 19 |
options.add_argument('--headless') |
| 20 |
options.add_argument('--no-sandbox') |
| 21 |
options.add_argument('--disable-gpu') |
| 22 |
options.add_argument('--disable-dev-shm-usage') |
| 23 |
options.add_argument('--profile-directory=Default') |
| 24 |
options.add_argument('--user-data-dir=' + self.data_dir) |
| 25 |
service = Service(executable_path=r'/usr/bin/chromedriver') |
| 26 |
self.driver = webdriver.Chrome(service=service, options=options) |
| 27 |
|
| 28 |
def tearDown(self): |
| 29 |
self.driver.close() |
| 30 |
|
| 31 |
def test_login_page(self): |
| 32 |
self.driver.get("http://localhost:8888/dmarc-srg/") |
| 33 |
self.assertIn("DMARC Reports", self.driver.title) |
| 34 |
|
| 35 |
vitals = WebDriverWait(self.driver, 60).until(lambda x: x.find_element(By.CLASS_NAME, "dialog")) |
| 36 |
|
| 37 |
self.assertIn("Authentication", vitals.text) |
| 38 |
self.assertIn("Password", vitals.text) |
| 39 |
|
| 40 |
if __name__ == '__main__': |
| 41 |
suite = unittest.TestLoader().loadTestsFromTestCase(TestDmarcSrgWeb) |
| 42 |
result = unittest.TextTestRunner(verbosity=2).run(suite) |
| 43 |
|
| 44 |
if not result.wasSuccessful(): |
| 45 |
sys.exit(1) |