TT#70901 selenium: add multithreading to selenium tests

- run tests with nose2 multithreading now. currently on 2 threads, since
anything higher kills my laptop.
- threads have their own subscriber, so that changing i.e the password wont
affect other tests. the amount of threads has to be changed in testrunner and
in the nose2 config files.
- tests are no longer named test_a, test_b, etc. since preperation and
cleanup functions are now done seperatley.
- webdriver creation has been moved into its own function, so changes to it
can be done easier
- fancy new messages when exectuing tests
- fixed tests bugs introduced with threading

Change-Id: I70f985dbde20af020bad9186a0b262f67b33de82
changes/84/37084/20
Nico Schedel 5 years ago
parent ac5c69679a
commit 8fa7c22646

@ -1,5 +1,6 @@
import os import os
import random import random
import time
from functions import Functions from functions import Functions
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
@ -119,9 +120,10 @@ def create_subscriber(driver, customername, domainname):
Functions.fill_element( Functions.fill_element(
driver, '//*[@id="domainidtable_filter"]//input', domainname) driver, '//*[@id="domainidtable_filter"]//input', domainname)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( WebDriverWait(driver, 10).until(EC.element_to_be_clickable((
By.XPATH, '//*[@id="domainidtable_paginate"]/a[4]'))) By.XPATH, '//*[@id="domainidtable"]//tr[1]//td'
driver.find_element_by_xpath( '[text()="%s"]' % domainname)))
'//*[@id="domainidtable_paginate"]/a[4]').click() Functions.click_js(
driver, '//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input')
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="webusername"]').send_keys('testuser') '//*[@id="webusername"]').send_keys('testuser')
driver.find_element_by_xpath( driver.find_element_by_xpath(

@ -41,3 +41,16 @@ def click_js(driver, element):
else: else:
webelement = driver.find_element_by_link_text(element) webelement = driver.find_element_by_link_text(element)
driver.execute_script("arguments[0].click();", webelement) driver.execute_script("arguments[0].click();", webelement)
def create_driver():
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
caps = DesiredCapabilities().FIREFOX
caps["pageLoadStrategy"] = "normal"
driver = webdriver.Firefox(
capabilities=caps, firefox_profile=profile,
service_log_path='/dev/null', )
driver.implicitly_wait(10)
driver.set_page_load_timeout(10)
return driver

@ -1,5 +1,6 @@
[unittest] [unittest]
plugins = nose2.plugins.junitxml plugins = nose2.plugins.junitxml
nose2.plugins.mp
exclude-plugins = nose2.plugins.failfast exclude-plugins = nose2.plugins.failfast
[junit-xml] [junit-xml]
@ -7,3 +8,7 @@ always-on = True
keep_restricted = False keep_restricted = False
path = /results/selenium.xml path = /results/selenium.xml
test_fullname = True test_fullname = True
[multiprocess]
always-on = True
processes = 2

@ -1,5 +1,6 @@
[unittest] [unittest]
plugins = nose2.plugins.junitxml plugins = nose2.plugins.junitxml
nose2.plugins.mp
exclude-plugins = nose2.plugins.failfast exclude-plugins = nose2.plugins.failfast
[junit-xml] [junit-xml]
@ -8,5 +9,6 @@ keep_restricted = False
path = selenium.xml path = selenium.xml
test_fullname = True test_fullname = True
[pretty-assert] [multiprocess]
always-on = True always-on = True
processes = 2

@ -1,9 +1,12 @@
import unittest import unittest
import os import os
import traceback
from multiprocessing import Value
import nose2 import nose2
import time import time
import functions.Collections as Collections import functions.Collections as Collections
import functions.Functions as Functions import functions.Functions as Functions
import selenium.common.exceptions
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
@ -11,40 +14,49 @@ from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
domainname = "thistextwillbereplaced" execs = Value('i', 0)
customername = "thistextwillalsobereplaced" customers = {}
filename = 0 filename = 0
def preparation():
global customers
driver = Functions.create_driver()
Collections.login_panel(driver)
for i in range(0, int(os.environ['THREADS'])):
customers[Collections.create_customer(
driver)] = Collections.create_domain(driver)
del i
for customer in customers.keys():
Collections.create_subscriber(driver, customer, customers[customer])
driver.quit()
def cleanup():
global customers
driver = Functions.create_driver()
Collections.login_panel(driver)
for customer in customers:
Collections.delete_customer(driver, customer)
Collections.delete_domain(driver, customers[customer])
driver.quit()
class testrun(unittest.TestCase): class testrun(unittest.TestCase):
def setUp(self): def setUp(self):
profile = webdriver.FirefoxProfile() global execs
profile.accept_untrusted_certs = True global customers
caps = DesiredCapabilities().FIREFOX self.driver = Functions.create_driver()
caps["pageLoadStrategy"] = "normal"
self.driver = webdriver.Firefox(
capabilities=caps, firefox_profile=profile, log_path='/dev/null')
self.driver.implicitly_wait(10)
self.driver.set_page_load_timeout(10)
self.longMessage = True self.longMessage = True
execs.value += 1
key = list(customers.keys())[execs.value % int(os.environ['THREADS'])]
self.domainname = customers[key]
def test_a_preparation(self): def test_login_page(self):
global domainname global customers
global customername
global filename global filename
filename = "test_a_preparation.png" filename = "test_login_page.png"
driver = self.driver
Collections.login_panel(driver)
domainname = Collections.create_domain(driver)
customername = Collections.create_customer(driver)
Collections.create_subscriber(driver, customername, domainname)
filename = 0
def test_b_login_logout(self):
global domainname
global filename
filename = "test_b_login_logout.png"
driver = self.driver driver = self.driver
driver.get(os.environ['CATALYST_SERVER']) driver.get(os.environ['CATALYST_SERVER'])
driver.find_element_by_xpath( driver.find_element_by_xpath(
@ -60,7 +72,7 @@ class testrun(unittest.TestCase):
.is_displayed(), "Error Message was not shown") .is_displayed(), "Error Message was not shown")
Functions.fill_element( Functions.fill_element(
driver, '//*[@id="csc-login-form"]//div//input[@type=' driver, '//*[@id="csc-login-form"]//div//input[@type='
'"text"]', "testuser@" + domainname) '"text"]', "testuser@" + self.domainname)
Functions.fill_element( Functions.fill_element(
driver, '//*[@id="csc-login-form"]//div//input[@type=' driver, '//*[@id="csc-login-form"]//div//input[@type='
'"password"]', "testpasswd") '"password"]', "testpasswd")
@ -143,12 +155,13 @@ class testrun(unittest.TestCase):
'Language was not changed back to English') 'Language was not changed back to English')
filename = 0 filename = 0
def test_c_call_blocking(self): def test_call_blocking(self):
global domainname global customers
global filename global filename
filename = "test_c_call_blocking.png" filename = "test_call_blocking.png"
driver = self.driver driver = self.driver
Collections.login_csc(driver, "testuser@" + domainname, "testpasswd") Collections.login_csc(
driver, "testuser@" + self.domainname, 'testpasswd')
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( WebDriverWait(driver, 10).until(EC.element_to_be_clickable((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Call Blocking")]'))) '[contains(text(), "Call Blocking")]')))
@ -189,7 +202,7 @@ class testrun(unittest.TestCase):
'"q-toggle")]/div[contains(@class, "active")]').is_displayed(), '"q-toggle")]/div[contains(@class, "active")]').is_displayed(),
"Option 'All anonymous incoming calls are blocked' was not " "Option 'All anonymous incoming calls are blocked' was not "
"enabled") "enabled")
self.assertEquals("12345", driver.find_element_by_xpath( self.assertEqual("12345", driver.find_element_by_xpath(
'//*[@id="q-app"]//div[contains(@class, "csc-blocked-number ' '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number '
'csc-list-item ")]//div[@class="q-item-label"]').text, 'csc-list-item ")]//div[@class="q-item-label"]').text,
"Number is not correct") "Number is not correct")
@ -212,7 +225,7 @@ class testrun(unittest.TestCase):
WebDriverWait(driver, 10).until(EC.invisibility_of_element(( WebDriverWait(driver, 10).until(EC.invisibility_of_element((
By.XPATH, '//*[@id="q-app"]//div[@class="csc-spinner"]/svg'))) By.XPATH, '//*[@id="q-app"]//div[@class="csc-spinner"]/svg')))
driver.implicitly_wait(10) driver.implicitly_wait(10)
self.assertEquals("54321", driver.find_element_by_xpath( self.assertEqual("54321", driver.find_element_by_xpath(
'//*[@id="q-app"]//div[contains(@class, "csc-blocked-number ' '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number '
'csc-list-item ")]//div[@class="q-item-label"]').text, 'csc-list-item ")]//div[@class="q-item-label"]').text,
"Number is not correct") "Number is not correct")
@ -255,7 +268,7 @@ class testrun(unittest.TestCase):
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@class="csc-form-actions row justify-center' '//*[@id="q-app"]//div[@class="csc-form-actions row justify-center'
'"]/button[2]').click() '"]/button[2]').click()
self.assertEquals("12345", driver.find_element_by_xpath( self.assertEqual("12345", driver.find_element_by_xpath(
'//*[@id="q-app"]//div[contains(@class, "csc-blocked-number ' '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number '
'csc-list-item ")]//div[@class="q-item-label"]').text, 'csc-list-item ")]//div[@class="q-item-label"]').text,
"Number is not correct") "Number is not correct")
@ -275,10 +288,10 @@ class testrun(unittest.TestCase):
'//*[@id="q-app"]//div//i[text()="check"]') '//*[@id="q-app"]//div//i[text()="check"]')
driver.execute_script("arguments[0].click();", elem) driver.execute_script("arguments[0].click();", elem)
driver.implicitly_wait(2) driver.implicitly_wait(2)
WebDriverWait(driver, 10).until(EC.invisibility_of_element(( WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//*[@id="q-app"]//div[@class="csc-spinner"]/svg'))) By.XPATH, '//*[@id="q-app"]//div[@class="csc-spinner"]/svg')))
driver.implicitly_wait(10) driver.implicitly_wait(10)
self.assertEquals("54321", driver.find_element_by_xpath( self.assertEqual("54321", driver.find_element_by_xpath(
'//*[@id="q-app"]//div[contains(@class, "csc-blocked-number ' '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number '
'csc-list-item ")]//div[@class="q-item-label"]').text, 'csc-list-item ")]//div[@class="q-item-label"]').text,
"Number is not correct") "Number is not correct")
@ -298,9 +311,16 @@ class testrun(unittest.TestCase):
'//*[@id="q-app"]//div[@class="csc-list-message"]' '//*[@id="q-app"]//div[@class="csc-list-message"]'
'[contains(text(), "No numbers found")]').is_displayed(), '[contains(text(), "No numbers found")]').is_displayed(),
"Number has not been deleted") "Number has not been deleted")
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( driver.implicitly_wait(2)
WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Privacy")]'))) '[contains(text(), "Privacy")]/div[@class="q-inner-loading '
'animate-fade absolute-full column flex-center"]')))
WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Privacy")]/div[@class="q-inner-loading '
'animate-fade absolute-full column flex-center"]')))
driver.implicitly_wait(10)
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="main-menu"]//div[@class="q-item-label"]' '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Privacy")]').click() '[contains(text(), "Privacy")]').click()
@ -323,12 +343,13 @@ class testrun(unittest.TestCase):
"/login/subscriber/#/login", "Logout failed") "/login/subscriber/#/login", "Logout failed")
filename = 0 filename = 0
def test_d_call_forward_after_hours(self): def test_call_forward_after_hours(self):
global domainname global customers
global filename global filename
filename = "test_d_call_forward_after_hours.png" filename = "test_call_forward_after_hours.png"
driver = self.driver driver = self.driver
Collections.login_csc(driver, "testuser@" + domainname, "testpasswd") Collections.login_csc(
driver, "testuser@" + self.domainname, 'testpasswd')
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( WebDriverWait(driver, 10).until(EC.element_to_be_clickable((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Call Forward")]'))) '[contains(text(), "Call Forward")]')))
@ -404,6 +425,10 @@ class testrun(unittest.TestCase):
'//*[@id="q-app"]//div[@class="add-destination-form"]//button' '//*[@id="q-app"]//div[@class="add-destination-form"]//button'
'/span[contains(text(), "Save")]').click() '/span[contains(text(), "Save")]').click()
driver.implicitly_wait(2) driver.implicitly_wait(2)
WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//div[class="q-loading animate-fade fullscreen column '
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
'text-white"]')))
WebDriverWait(driver, 10).until(EC.invisibility_of_element_located(( WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//div[class="q-loading animate-fade fullscreen column ' By.XPATH, '//div[class="q-loading animate-fade fullscreen column '
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat ' 'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
@ -466,12 +491,21 @@ class testrun(unittest.TestCase):
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat ' 'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
'text-white"]'))) 'text-white"]')))
driver.implicitly_wait(10) driver.implicitly_wait(10)
driver.find_element_by_xpath( Functions.click_js(
driver,
'//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]' '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]'
'/div[@tabindex="0"]').click() '/div[@tabindex="0"]/div[@class="q-option-inner '
driver.find_element_by_xpath( 'relative-position"]')
'//*[@id="q-app"]//div[contains(@class, "csc-destination ' driver.implicitly_wait(2)
'csc-own-phone")]/div[contains(@class, "dest-btns")]').click() WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//div[@class="q-loading animate-fade fullscreen column '
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
'text-white"]')))
WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//div[@class="q-loading animate-fade fullscreen column '
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
'text-white"]')))
driver.implicitly_wait(10)
self.assertTrue(driver.find_element_by_xpath( self.assertTrue(driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle"' '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle"'
')]/div[@class="q-option-inner relative-position ' ')]/div[@class="q-option-inner relative-position '
@ -499,14 +533,14 @@ class testrun(unittest.TestCase):
"im busy' is missing") "im busy' is missing")
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@class="q-tab column flex-center ' '//*[@id="q-app"]//div[@class="q-tab column flex-center '
'relative-position icon-and-label"]//span[@class="q-tab-label"]' 'relative-position icon-and-label"]//span[contains'
).click() '(text(), "Add new")]').click()
Functions.fill_element( Functions.fill_element(
driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/'
'div[1]//input', 'testsourceset') 'div[1]//input', 'firsttestsourceset')
Functions.fill_element( Functions.fill_element(
driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/'
'div[2]//input', 'testsource') 'div[2]//input', 'firsttestsource')
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div' '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div'
'[@tabindex=0]').click() '[@tabindex=0]').click()
@ -526,10 +560,10 @@ class testrun(unittest.TestCase):
'text-white"]'))) 'text-white"]')))
driver.implicitly_wait(10) driver.implicitly_wait(10)
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div/span[contains(text(), "testsourceset")]' '//*[@id="q-app"]//div/span[contains'
).click() '(text(), "firsttestsourceset")]').click()
self.assertTrue(driver.find_element_by_xpath( self.assertTrue(driver.find_element_by_xpath(
'//*[@id="q-app"]//div[contains(text(), "testsource")]' '//*[@id="q-app"]//div[contains(text(), "firsttestsource")]'
).is_displayed(), "Source was not found") ).is_displayed(), "Source was not found")
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@class="sources-section"]/button').click() '//*[@id="q-app"]//div[@class="sources-section"]/button').click()
@ -569,7 +603,7 @@ class testrun(unittest.TestCase):
"Second Source was not deleted") "Second Source was not deleted")
driver.implicitly_wait(10) driver.implicitly_wait(10)
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[contains(text(), "testsource")]/../' '//*[@id="q-app"]//div[contains(text(), "firsttestsource")]/../'
'div[2]').click() 'div[2]').click()
self.assertTrue(driver.find_element_by_xpath( self.assertTrue(driver.find_element_by_xpath(
'/html/body//div[@class="q-alert row no-wrap shadow-2 ' '/html/body//div[@class="q-alert row no-wrap shadow-2 '
@ -665,7 +699,8 @@ class testrun(unittest.TestCase):
'text-white"]'))) 'text-white"]')))
time.sleep(1) time.sleep(1)
self.assertFalse(driver.find_elements_by_xpath( self.assertFalse(driver.find_elements_by_xpath(
'//*[@id="q-app"]//div/span[contains(text(), "testsourceset")]'), '//*[@id="q-app"]//div/span[contains'
'(text(), "firsttestsourceset")]'),
"Second Source Set was not deleted") "Second Source Set was not deleted")
driver.implicitly_wait(10) driver.implicitly_wait(10)
Collections.logout_csc(driver) Collections.logout_csc(driver)
@ -674,12 +709,13 @@ class testrun(unittest.TestCase):
"/login/subscriber/#/login", "Logout failed") "/login/subscriber/#/login", "Logout failed")
filename = 0 filename = 0
def test_e_call_forward_always(self): def test_call_forward_always(self):
global domainname global customers
global filename global filename
filename = "test_e_call_forward_always.png" filename = "test_call_forward_always.png"
driver = self.driver driver = self.driver
Collections.login_csc(driver, "testuser@" + domainname, "testpasswd") Collections.login_csc(
driver, "testuser@" + self.domainname, 'testpasswd')
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( WebDriverWait(driver, 10).until(EC.element_to_be_clickable((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Call Forward")]'))) '[contains(text(), "Call Forward")]')))
@ -718,6 +754,10 @@ class testrun(unittest.TestCase):
'//*[@id="q-app"]//div[@class="add-destination-form"]//button' '//*[@id="q-app"]//div[@class="add-destination-form"]//button'
'/span[contains(text(), "Save")]').click() '/span[contains(text(), "Save")]').click()
driver.implicitly_wait(2) driver.implicitly_wait(2)
WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//div[class="q-loading animate-fade fullscreen column '
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
'text-white"]')))
WebDriverWait(driver, 10).until(EC.invisibility_of_element_located(( WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//div[class="q-loading animate-fade fullscreen column ' By.XPATH, '//div[class="q-loading animate-fade fullscreen column '
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat ' 'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
@ -823,12 +863,21 @@ class testrun(unittest.TestCase):
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat ' 'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
'text-white"]'))) 'text-white"]')))
driver.implicitly_wait(10) driver.implicitly_wait(10)
driver.find_element_by_xpath( Functions.click_js(
driver,
'//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]' '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]'
'/div[@tabindex="0"]').click() '/div[@tabindex="0"]/div[@class="q-option-inner '
driver.find_element_by_xpath( 'relative-position"]')
'//*[@id="q-app"]//div[contains(@class, "csc-destination ' driver.implicitly_wait(2)
'csc-own-phone")]/div[contains(@class, "dest-btns")]').click() WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//div[@class="q-loading animate-fade fullscreen column '
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
'text-white"]')))
WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//div[@class="q-loading animate-fade fullscreen column '
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
'text-white"]')))
driver.implicitly_wait(10)
self.assertTrue(driver.find_element_by_xpath( self.assertTrue(driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle"' '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle"'
')]/div[@class="q-option-inner relative-position ' ')]/div[@class="q-option-inner relative-position '
@ -864,14 +913,14 @@ class testrun(unittest.TestCase):
"im offline' is missing") "im offline' is missing")
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@class="q-tab column flex-center ' '//*[@id="q-app"]//div[@class="q-tab column flex-center '
'relative-position icon-and-label"]//span[@class="q-tab-label"]' 'relative-position icon-and-label"]//span[contains'
).click() '(text(), "Add new")]').click()
Functions.fill_element( Functions.fill_element(
driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/'
'div[1]//input', 'testsourceset') 'div[1]//input', 'secondtestsourceset')
Functions.fill_element( Functions.fill_element(
driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/'
'div[2]//input', 'testsource') 'div[2]//input', 'secondtestsource')
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div' '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div'
'[@tabindex=0]').click() '[@tabindex=0]').click()
@ -891,10 +940,10 @@ class testrun(unittest.TestCase):
'text-white"]'))) 'text-white"]')))
driver.implicitly_wait(10) driver.implicitly_wait(10)
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div/span[contains(text(), "testsourceset")]' '//*[@id="q-app"]//div/span[contains'
).click() '(text(), "secondtestsourceset")]').click()
self.assertTrue(driver.find_element_by_xpath( self.assertTrue(driver.find_element_by_xpath(
'//*[@id="q-app"]//div[contains(text(), "testsource")]' '//*[@id="q-app"]//div[contains(text(), "secondtestsource")]'
).is_displayed(), "Source was not found") ).is_displayed(), "Source was not found")
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@class="sources-section"]/button').click() '//*[@id="q-app"]//div[@class="sources-section"]/button').click()
@ -934,7 +983,7 @@ class testrun(unittest.TestCase):
"Second Source was not deleted") "Second Source was not deleted")
driver.implicitly_wait(10) driver.implicitly_wait(10)
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[contains(text(), "testsource")]/../' '//*[@id="q-app"]//div[contains(text(), "secondtestsource")]/../'
'div[2]').click() 'div[2]').click()
self.assertTrue(driver.find_element_by_xpath( self.assertTrue(driver.find_element_by_xpath(
'/html/body//div[@class="q-alert row no-wrap shadow-2 ' '/html/body//div[@class="q-alert row no-wrap shadow-2 '
@ -1030,7 +1079,8 @@ class testrun(unittest.TestCase):
'text-white"]'))) 'text-white"]')))
time.sleep(1) time.sleep(1)
self.assertFalse(driver.find_elements_by_xpath( self.assertFalse(driver.find_elements_by_xpath(
'//*[@id="q-app"]//div/span[contains(text(), "testsourceset")]'), '//*[@id="q-app"]//div/span[contains'
'(text(), "secondtestsourceset")]'),
"Second Source Set was not deleted") "Second Source Set was not deleted")
driver.implicitly_wait(10) driver.implicitly_wait(10)
Collections.logout_csc(driver) Collections.logout_csc(driver)
@ -1039,12 +1089,13 @@ class testrun(unittest.TestCase):
"/login/subscriber/#/login", "Logout failed") "/login/subscriber/#/login", "Logout failed")
filename = 0 filename = 0
def test_f_call_forward_company_hours(self): def test_call_forward_company_hours(self):
global domainname global customers
global filename global filename
filename = "test_f_call_forward_company_hours.png" filename = "test_call_forward_company_hours.png"
driver = self.driver driver = self.driver
Collections.login_csc(driver, "testuser@" + domainname, "testpasswd") Collections.login_csc(
driver, "testuser@" + self.domainname, 'testpasswd')
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( WebDriverWait(driver, 10).until(EC.element_to_be_clickable((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Call Forward")]'))) '[contains(text(), "Call Forward")]')))
@ -1186,12 +1237,21 @@ class testrun(unittest.TestCase):
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat ' 'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
'text-white"]'))) 'text-white"]')))
driver.implicitly_wait(10) driver.implicitly_wait(10)
driver.find_element_by_xpath( Functions.click_js(
driver,
'//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]' '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]'
'/div[@tabindex="0"]').click() '/div[@tabindex="0"]/div[@class="q-option-inner '
driver.find_element_by_xpath( 'relative-position"]')
'//*[@id="q-app"]//div[contains(@class, "csc-destination ' driver.implicitly_wait(2)
'csc-own-phone")]/div[contains(@class, "dest-btns")]').click() WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//div[@class="q-loading animate-fade fullscreen column '
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
'text-white"]')))
WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((
By.XPATH, '//div[@class="q-loading animate-fade fullscreen column '
'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat '
'text-white"]')))
driver.implicitly_wait(10)
self.assertTrue(driver.find_element_by_xpath( self.assertTrue(driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle"' '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle"'
')]/div[@class="q-option-inner relative-position ' ')]/div[@class="q-option-inner relative-position '
@ -1219,14 +1279,14 @@ class testrun(unittest.TestCase):
"im busy' is missing") "im busy' is missing")
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@class="q-tab column flex-center ' '//*[@id="q-app"]//div[@class="q-tab column flex-center '
'relative-position icon-and-label"]//span[@class="q-tab-label"]' 'relative-position icon-and-label"]//span[contains'
).click() '(text(), "Add new")]').click()
Functions.fill_element( Functions.fill_element(
driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/'
'div[1]//input', 'testsourceset') 'div[1]//input', 'thirdtestsourceset')
Functions.fill_element( Functions.fill_element(
driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/'
'div[2]//input', 'testsource') 'div[2]//input', 'thirdtestsource')
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div' '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div'
'[@tabindex=0]').click() '[@tabindex=0]').click()
@ -1246,10 +1306,10 @@ class testrun(unittest.TestCase):
'text-white"]'))) 'text-white"]')))
driver.implicitly_wait(10) driver.implicitly_wait(10)
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div/span[contains(text(), "testsourceset")]' '//*[@id="q-app"]//div/span[contains'
).click() '(text(), "thirdtestsourceset")]').click()
self.assertTrue(driver.find_element_by_xpath( self.assertTrue(driver.find_element_by_xpath(
'//*[@id="q-app"]//div[contains(text(), "testsource")]' '//*[@id="q-app"]//div[contains(text(), "thirdtestsource")]'
).is_displayed(), "Source was not found") ).is_displayed(), "Source was not found")
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[@class="sources-section"]/button').click() '//*[@id="q-app"]//div[@class="sources-section"]/button').click()
@ -1289,7 +1349,7 @@ class testrun(unittest.TestCase):
"Second Source was not deleted") "Second Source was not deleted")
driver.implicitly_wait(10) driver.implicitly_wait(10)
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="q-app"]//div[contains(text(), "testsource")]/../' '//*[@id="q-app"]//div[contains(text(), "thirdtestsource")]/../'
'div[2]').click() 'div[2]').click()
self.assertTrue(driver.find_element_by_xpath( self.assertTrue(driver.find_element_by_xpath(
'/html/body//div[@class="q-alert row no-wrap shadow-2 ' '/html/body//div[@class="q-alert row no-wrap shadow-2 '
@ -1385,7 +1445,8 @@ class testrun(unittest.TestCase):
'text-white"]'))) 'text-white"]')))
time.sleep(1) time.sleep(1)
self.assertFalse(driver.find_elements_by_xpath( self.assertFalse(driver.find_elements_by_xpath(
'//*[@id="q-app"]//div/span[contains(text(), "testsourceset")]'), '//*[@id="q-app"]//div/span[contains'
'(text(), "thirdtestsourceset")]'),
"Second Source Set was not deleted") "Second Source Set was not deleted")
driver.implicitly_wait(10) driver.implicitly_wait(10)
Collections.logout_csc(driver) Collections.logout_csc(driver)
@ -1394,12 +1455,13 @@ class testrun(unittest.TestCase):
"/login/subscriber/#/login", "Logout failed") "/login/subscriber/#/login", "Logout failed")
filename = 0 filename = 0
def test_g_conference_conversations(self): def test_conference_conversations(self):
global domainname global customers
global filename global filename
filename = "test_g_conference_conversations.png" filename = "test_conference_conversations.png"
driver = self.driver driver = self.driver
Collections.login_csc(driver, "testuser@" + domainname, "testpasswd") Collections.login_csc(
driver, "testuser@" + self.domainname, 'testpasswd')
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( WebDriverWait(driver, 10).until(EC.element_to_be_clickable((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Join conference")]'))) '[contains(text(), "Join conference")]')))
@ -1428,28 +1490,28 @@ class testrun(unittest.TestCase):
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="main-menu"]//div[@class="q-item-label"]' '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Conversations")]').click() '[contains(text(), "Conversations")]').click()
self.assertEquals(driver.find_element_by_xpath( self.assertEqual(driver.find_element_by_xpath(
'//*[@id="csc-conversation-content"]/div[@class="row justify-' '//*[@id="csc-conversation-content"]/div[@class="row justify-'
'center csc-conversation-list-message"]').text, 'No Calls, ' 'center csc-conversation-list-message"]').text, 'No Calls, '
'Voicemails or Faxes found', "Section 'All' is not empty") 'Voicemails or Faxes found', "Section 'All' is not empty")
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller ' '//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller '
'row no-wrap"]//span[contains(text(), "Calls")]').click() 'row no-wrap"]//span[contains(text(), "Calls")]').click()
self.assertEquals(driver.find_element_by_xpath( self.assertEqual(driver.find_element_by_xpath(
'//*[@id="csc-conversation-content"]/div[@class="row justify-' '//*[@id="csc-conversation-content"]/div[@class="row justify-'
'center csc-conversation-list-message"]').text, 'No Calls found', 'center csc-conversation-list-message"]').text, 'No Calls found',
"Section 'Calls' is notempty") "Section 'Calls' is notempty")
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller ' '//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller '
'row no-wrap"]//span[contains(text(), "Faxes")]').click() 'row no-wrap"]//span[contains(text(), "Faxes")]').click()
self.assertEquals(driver.find_element_by_xpath( self.assertEqual(driver.find_element_by_xpath(
'//*[@id="csc-conversation-content"]/div[@class="row justify-' '//*[@id="csc-conversation-content"]/div[@class="row justify-'
'center csc-conversation-list-message"]').text, 'No Faxes found', 'center csc-conversation-list-message"]').text, 'No Faxes found',
"Section 'Faxes' is not empty") "Section 'Faxes' is not empty")
driver.find_element_by_xpath( driver.find_element_by_xpath(
'//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller ' '//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller '
'row no-wrap"]//span[contains(text(), "Voicemails")]').click() 'row no-wrap"]//span[contains(text(), "Voicemails")]').click()
self.assertEquals(driver.find_element_by_xpath( self.assertEqual(driver.find_element_by_xpath(
'//*[@id="csc-conversation-content"]/div[@class="row justify-' '//*[@id="csc-conversation-content"]/div[@class="row justify-'
'center csc-conversation-list-message"]').text, 'No Voicemails ' 'center csc-conversation-list-message"]').text, 'No Voicemails '
'found', "Section 'Voicemails' is not empty") 'found', "Section 'Voicemails' is not empty")
@ -1459,12 +1521,13 @@ class testrun(unittest.TestCase):
"/login/subscriber/#/login", "Logout failed") "/login/subscriber/#/login", "Logout failed")
filename = 0 filename = 0
def test_h_reminder(self): def test_reminder(self):
global domainname global customers
global filename global filename
filename = "test_h_reminder.png" filename = "test_reminder.png"
driver = self.driver driver = self.driver
Collections.login_csc(driver, "testuser@" + domainname, "testpasswd") Collections.login_csc(
driver, "testuser@" + self.domainname, 'testpasswd')
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( WebDriverWait(driver, 10).until(EC.element_to_be_clickable((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Reminder")]'))) '[contains(text(), "Reminder")]')))
@ -1520,12 +1583,13 @@ class testrun(unittest.TestCase):
"/login/subscriber/#/login", "Logout failed") "/login/subscriber/#/login", "Logout failed")
filename = 0 filename = 0
def test_i_settings(self): def test_settings(self):
global domainname global customers
global filename global filename
filename = "test_i_settings.png" filename = "test_settings.png"
driver = self.driver driver = self.driver
Collections.login_csc(driver, "testuser@" + domainname, "testpasswd") Collections.login_csc(
driver, "testuser@" + self.domainname, 'testpasswd')
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( WebDriverWait(driver, 10).until(EC.element_to_be_clickable((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Reminder")]'))) '[contains(text(), "Reminder")]')))
@ -1618,7 +1682,8 @@ class testrun(unittest.TestCase):
self.assertEqual( self.assertEqual(
driver.current_url, os.environ['CATALYST_SERVER'] + driver.current_url, os.environ['CATALYST_SERVER'] +
"/login/subscriber/#/login", "Logout failed") "/login/subscriber/#/login", "Logout failed")
Collections.login_csc(driver, "testuser@" + domainname, "pass1234") Collections.login_csc(
driver, "testuser@" + self.domainname, 'pass1234')
self.assertEqual("testuser", driver.find_element_by_xpath( self.assertEqual("testuser", driver.find_element_by_xpath(
'//*[@id="csc-header-toolbar"]//div//span[contains(text(), ' '//*[@id="csc-header-toolbar"]//div//span[contains(text(), '
'"testuser")]').text, "Login failed") '"testuser")]').text, "Login failed")
@ -1648,12 +1713,16 @@ class testrun(unittest.TestCase):
"/login/subscriber/#/login", "Logout failed") "/login/subscriber/#/login", "Logout failed")
filename = 0 filename = 0
def test_j_speed_dial(self): def test_speed_dial(self):
global domainname global customers
global filename global filename
filename = "test_j_speed_dial.png" filename = "test_speed_dial.png"
driver = self.driver driver = self.driver
Collections.login_csc(driver, "testuser@" + domainname, "testpasswd") Collections.login_csc(
driver, "testuser@" + self.domainname, 'testpasswd')
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Speed Dial")]')))
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( WebDriverWait(driver, 10).until(EC.element_to_be_clickable((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Speed Dial")]'))) '[contains(text(), "Speed Dial")]')))
@ -1735,12 +1804,13 @@ class testrun(unittest.TestCase):
"/login/subscriber/#/login", "Logout failed") "/login/subscriber/#/login", "Logout failed")
filename = 0 filename = 0
def test_k_voicebox(self): def test_voicebox(self):
global domainname global customers
global filename global filename
filename = "test_k_voicebox.png" filename = "test_voicebox.png"
driver = self.driver driver = self.driver
Collections.login_csc(driver, "testuser@" + domainname, "testpasswd") Collections.login_csc(
driver, "testuser@" + self.domainname, 'testpasswd')
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( WebDriverWait(driver, 10).until(EC.element_to_be_clickable((
By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]'
'[contains(text(), "Voicebox")]'))) '[contains(text(), "Voicebox")]')))
@ -1804,36 +1874,30 @@ class testrun(unittest.TestCase):
"/login/subscriber/#/login", "Logout failed") "/login/subscriber/#/login", "Logout failed")
filename = 0 filename = 0
def test_z_cleanup(self):
global domainname
global customername
global filename
filename = "test_z_cleanup.png"
driver = self.driver
Collections.login_panel(driver)
Collections.delete_customer(driver, customername)
Functions.fill_element(
driver, '//*[@id="Customer_table_filter"]//input', customername)
self.assertTrue(driver.find_element_by_css_selector(
'#Customer_table tr > td.dataTables_empty').is_displayed(),
"Customer has not been deleted")
Collections.delete_domain(driver, domainname)
Functions.fill_element(
driver, '//*[@id="Domain_table_filter"]//input', domainname)
self.assertTrue(driver.find_element_by_css_selector(
'#Domain_table tr > td.dataTables_empty').is_displayed(),
"Domain has not been deleted")
filename = 0
def tearDown(self): def tearDown(self):
global customers
global filename global filename
driver = self.driver driver = self.driver
driver.implicitly_wait(10)
if filename: if filename:
driver.save_screenshot('/results/' + filename) driver.save_screenshot('/results/' + filename)
filename = 0 filename = 0
driver.close() driver.quit()
if __name__ == '__main__': if __name__ == '__main__':
nose2.main() print('Preparing Domain, Customer and Subscriber for NGCP CSC tests ...')
try:
preparation()
except Exception as e:
print('Preperation failed! See logs below for more details')
print('--------------------------------------------------------------')
traceback.print_exc()
print('--------------------------------------------------------------')
quit(1)
print('Preperation successful, running tests now ...')
nose2.main(exit=False)
try:
cleanup()
except Exception as e:
traceback.print_exc()
quit(1)

@ -44,9 +44,6 @@ firefox --version
# ensure we don't leave any process behind causing problems with re-execution # ensure we don't leave any process behind causing problems with re-execution
pkill -f 'geckodriver' || true pkill -f 'geckodriver' || true
DISPLAY=:99 ~/geckodriver -p 4444 --log fatal & DISPLAY=:99 ~/geckodriver -p 4444 --log fatal &
#DISPLAY=:99 ~/geckodriver -p 5555 --log fatal &
#DISPLAY=:99 ~/geckodriver -p 6666 --log fatal &
#DISPLAY=:99 ~/geckodriver -p 7777 --log fatal &
echo "################################################################################" echo "################################################################################"
echo "Finished main setup, now running tests ..." echo "Finished main setup, now running tests ..."
@ -58,13 +55,16 @@ RC=0
export CATALYST_SERVER="https://${SERVER}" export CATALYST_SERVER="https://${SERVER}"
cd t/selenium cd t/selenium
#Change thread count here and in nose2 config files
export THREADS=2
if [ "${OUTPUT_TYPE:-}" = "junit" ] ; then if [ "${OUTPUT_TYPE:-}" = "junit" ] ; then
export JENKINS=1 export JENKINS=1
nose2 -v -c nose2cfg/jenkinstest.cfg | \ python3 testrun.py -v -c nose2cfg/jenkinstest.cfg | \
tee -a "${OUTPUT_DIRECTORY}/selenium.xml" tee -a "${OUTPUT_DIRECTORY}/selenium.xml"
RC="${PIPESTATUS[0]}" RC="${PIPESTATUS[0]}"
else else
nose2 -v -c nose2cfg/localtest.cfg || RC=$? python3 testrun.py -v -c nose2cfg/localtest.cfg|| RC=$?
fi fi
echo "Finished test execution, test execution returned with exit code ${RC}." echo "Finished test execution, test execution returned with exit code ${RC}."

Loading…
Cancel
Save