diff --git a/t/selenium/functions/Collections.py b/t/selenium/functions/Collections.py index 46d44f30..43feef83 100644 --- a/t/selenium/functions/Collections.py +++ b/t/selenium/functions/Collections.py @@ -7,6 +7,25 @@ from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By +def login(driver, name, pwd): + driver.get(os.environ['CATALYST_SERVER']) + driver.find_element_by_xpath( + '//*[@id="csc-login-form"]//div//input[@type="text"]' + ).send_keys(name) + driver.find_element_by_xpath( + '//*[@id="csc-login-form"]//div//input[@type="password"]' + ).send_keys(pwd) + driver.find_element_by_xpath( + '//*[@id="csc-login"]//div//button').click() + + +def logout(driver): + driver.find_element_by_xpath( + '//*[@id="csc-header-toolbar"]/div[1]/button').click() + driver.find_element_by_xpath( + '/html/body//div[contains(text(), "Logout")]').click() + + def create_subscriber(driver): driver.get(os.environ['CATALYST_SERVER'] + ":1443/logout") driver.get(os.environ['CATALYST_SERVER'] + ":1443") diff --git a/t/selenium/test_login.py b/t/selenium/testrun.py similarity index 77% rename from t/selenium/test_login.py rename to t/selenium/testrun.py index 932b6a5f..e9ee8bd1 100644 --- a/t/selenium/test_login.py +++ b/t/selenium/testrun.py @@ -11,7 +11,7 @@ from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By -class test_login(unittest.TestCase): +class testrun(unittest.TestCase): def setUp(self): profile = webdriver.FirefoxProfile() profile.accept_untrusted_certs = True @@ -21,10 +21,10 @@ class test_login(unittest.TestCase): capabilities=caps, firefox_profile=profile, log_path='/dev/null') self.driver.implicitly_wait(10) self.driver.set_page_load_timeout(10) + Collections.create_subscriber(self.driver) - def test_login(self): + def test_login_logout(self): driver = self.driver - Collections.create_subscriber(driver) driver.find_element_by_link_text('Expand Groups').click() domainname = driver.find_element_by_xpath( '//*[@id="subscribers_table"]//tr[1]/td[3]').text @@ -37,6 +37,9 @@ class test_login(unittest.TestCase): ).send_keys('user') driver.find_element_by_xpath( '//*[@id="csc-login"]//div//button').click() + self.assertTrue(driver.find_element_by_xpath( + '/html/body/div[contains(@class, "q-alert-container")]') + .is_displayed(), "Error Message was shown") driver.find_element_by_xpath( '//*[@id="csc-login-form"]//div//input[@type="text"]' ).send_keys(Keys.CONTROL + "a") @@ -57,11 +60,16 @@ class test_login(unittest.TestCase): ).send_keys('testpasswd') driver.find_element_by_xpath( '//*[@id="csc-login"]//div//button').click() - self.assertEqual("testuser", (driver.find_element_by_xpath( + self.assertEqual("testuser", driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]//div//span[contains(text(), ' - '"testuser")]').text) - ) - WebDriverWait(driver, 1) + '"testuser")]').text, "Successfully logged in") + driver.find_element_by_xpath( + '//*[@id="csc-header-toolbar"]/div[1]/button').click() + driver.find_element_by_xpath( + '/html/body//div[contains(text(), "Logout")]').click() + self.assertEqual( + driver.current_url, os.environ['CATALYST_SERVER'] + + "/login/subscriber/#/login", "Successfully logged out") def tearDown(self): driver = self.driver