TT#70901 selenium: more improvements to login test

- renamed test_login to testrun.py
- put creation/deletion of subscriber in setUp() and tearDown()
- test if logout works
- add functions login() and logout() for use later
- assert statements now have messages to print

Change-Id: Ieb7fb9c1bb8c5df082e90481577920010c038157
changes/63/35563/5
Nico Schedel 6 years ago
parent 25a29367f5
commit 113292a90b

@ -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")

@ -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
Loading…
Cancel
Save