From 220b59ede7d2d918e2e6f09117c7ffa0f8852ef0 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 29 Apr 2020 10:28:41 +0200 Subject: [PATCH] TT#79804 don't break lines on xpath * create Functions.step to reduce code Change-Id: Ie2b1994478710a18e258e73bbc089a473d57c607 --- t/selenium/functions/Collections.py | 79 +- t/selenium/functions/Functions.py | 16 +- t/selenium/functions/__init__.py | 0 t/selenium/testrun.py | 1282 +++++++++------------------ 4 files changed, 476 insertions(+), 901 deletions(-) create mode 100644 t/selenium/functions/__init__.py diff --git a/t/selenium/functions/Collections.py b/t/selenium/functions/Collections.py index 3beca015..524d22f6 100644 --- a/t/selenium/functions/Collections.py +++ b/t/selenium/functions/Collections.py @@ -1,12 +1,6 @@ import os import random -import time from functions import Functions -from selenium import webdriver -from selenium.webdriver.common.keys import Keys -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.common.by import By def login_csc(driver, name, pwd): @@ -22,8 +16,7 @@ def login_csc(driver, name, pwd): def logout_csc(driver): - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="csc-header-toolbar"]/div[1]/button'))) + Functions.step(driver, '//*[@id="csc-header-toolbar"]/div[1]/button') driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/div[1]/button').click() driver.find_element_by_xpath( @@ -48,14 +41,13 @@ def logout_panel(driver): def create_customer(driver, name=None): if not name: name = 'customer' + str(random.randint(1, 100000)) + 'test' - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-nav"]//*[contains(text(),"Settings")]'))) + Functions.step( + driver, '//*[@id="main-nav"]//*[contains(text(),"Settings")]') driver.find_element_by_xpath( '//*[@id="main-nav"]//*[contains(text(),"Settings")]').click() driver.find_element_by_link_text('Customers').click() driver.find_element_by_link_text('Create Customer').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="contactidtable"]//tr[1]//td/input'))) + Functions.step(driver, '//*[@id="contactidtable"]//tr[1]//td/input') Functions.scroll_to_element( driver, '//*[@id="contactidtable"]//tr[1]//td/input') driver.find_element_by_xpath( @@ -73,8 +65,8 @@ def create_customer(driver, name=None): def delete_customer(driver, name): - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-nav"]//*[contains(text(),"Settings")]'))) + Functions.step( + driver, '//*[@id="main-nav"]//*[contains(text(),"Settings")]') driver.find_element_by_xpath( '//*[@id="main-nav"]//*[contains(text(),"Settings")]').click() driver.find_element_by_link_text('Customers').click() @@ -85,18 +77,16 @@ def delete_customer(driver, name): '#Customer_table tr > td.dataTables_empty') Functions.fill_element( driver, '//*[@id="Customer_table_filter"]//input', name) - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="Customer_table"]//tr[1]//td' - '[text()="%s"]' % name))) + Functions.step( + driver, '//*[@id="Customer_table"]//tr[1]//td[text()="%s"]' % name) Functions.click_js( - driver, '//*[@id="Customer_table"]//tr[1]//td//a[contains(text(),' - ' "Terminate")]') + driver, '//*[@id="Customer_table"]//tr[1]//td//a[contains(text(), "Terminate")]') driver.find_element_by_xpath('//*[@id="dataConfirmOK"]').click() def create_subscriber(driver, customername, domainname): - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-nav"]//*[contains(text(),"Settings")]'))) + Functions.step( + driver, '//*[@id="main-nav"]//*[contains(text(),"Settings")]') driver.find_element_by_xpath( '//*[@id="main-nav"]//*[contains(text(),"Settings")]').click() driver.find_element_by_link_text('Customers').click() @@ -107,17 +97,14 @@ def create_subscriber(driver, customername, domainname): '#Customer_table tr > td.dataTables_empty') Functions.fill_element( driver, '//*[@id="Customer_table_filter"]//input', customername) - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="Customer_table"]//tr[1]//td' - '[text()="%s"]' % customername))) + Functions.step( + driver, '//*[@id="Customer_table"]//tr[1]//td[text()="%s"]' % customername) Functions.click_js( - driver, '//*[@id="Customer_table"]//tr[1]//td//a[contains(text(),' - ' "Details")]') + driver, '//*[@id="Customer_table"]//tr[1]//td//a[contains(text(), "Details")]') driver.find_element_by_link_text('Expand Groups').click() Functions.scroll_to_element(driver, 'Subscribers') driver.find_element_by_link_text("Create Subscriber").click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable( - (By.XPATH, '//*[@id="domainidtable_paginate"]/a[4]'))) + Functions.step(driver, '//*[@id="domainidtable_paginate"]/a[4]') Functions.fill_element( driver, '//*[@id="domainidtable_filter"]//input', 'thisshouldnotexist') @@ -125,9 +112,8 @@ def create_subscriber(driver, customername, domainname): '#domainidtable tr > td.dataTables_empty') Functions.fill_element( driver, '//*[@id="domainidtable_filter"]//input', domainname) - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="domainidtable"]//tr[1]//td' - '[text()="%s"]' % domainname))) + Functions.step( + driver, '//*[@id="domainidtable"]//tr[1]//td[text()="%s"]' % domainname) Functions.click_js( driver, '//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input') driver.find_element_by_xpath( @@ -142,8 +128,8 @@ def create_subscriber(driver, customername, domainname): def delete_subscriber(driver, customername): - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-nav"]//*[contains(text(),"Settings")]'))) + Functions.step( + driver, '//*[@id="main-nav"]//*[contains(text(),"Settings")]') driver.find_element_by_xpath( '//*[@id="main-nav"]//*[contains(text(),"Settings")]').click() driver.find_element_by_link_text('Customers').click() @@ -154,31 +140,26 @@ def delete_subscriber(driver, customername): '#Customer_table tr > td.dataTables_empty') Functions.fill_element( driver, '//*[@id="Customer_table_filter"]//input', customername) - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="Customer_table"]//tr[1]//td' - '[text()="%s"]' % customername))) + Functions.step( + driver, '//*[@id="Customer_table"]//tr[1]//td[text()="%s"]' % customername) Functions.click_js( - driver, '//*[@id="Customer_table"]//tr[1]//td//a[contains(text(),' - ' "Details")]') + driver, '//*[@id="Customer_table"]//tr[1]//td//a[contains(text(), "Details")]') driver.find_element_by_link_text('Expand Groups').click() Functions.scroll_to_element(driver, 'Subscribers') Functions.click_js( - driver, '//*[@id="subscribers_table"]//tr[1]//td//a[contains(text(), ' - '"Terminate")]') + driver, '//*[@id="subscribers_table"]//tr[1]//td//a[contains(text(), "Terminate")]') driver.find_element_by_xpath('//*[@id="dataConfirmOK"]').click() def create_domain(driver, name=None): if not name: name = 'domain' + str(random.randint(1, 100000)) + 'test' - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-nav"]//*[contains(text(),"Settings")]'))) + Functions.step(driver, '//*[@id="main-nav"]//*[contains(text(),"Settings")]') driver.find_element_by_xpath( '//*[@id="main-nav"]//*[contains(text(),"Settings")]').click() driver.find_element_by_link_text('Domains').click() driver.find_element_by_link_text('Create Domain').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="reselleridtable"]//tr[1]/td[5]/input'))) + Functions.step(driver, '//*[@id="reselleridtable"]//tr[1]/td[5]/input') driver.find_element_by_xpath( '//*[@id="reselleridtable"]//tr[1]/td[5]/input').click() Functions.fill_element(driver, '//*[@id="domain"]', name) @@ -187,8 +168,7 @@ def create_domain(driver, name=None): def delete_domain(driver, name): - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-nav"]//*[contains(text(),"Settings")]'))) + Functions.step(driver, '//*[@id="main-nav"]//*[contains(text(),"Settings")]') driver.find_element_by_xpath( '//*[@id="main-nav"]//*[contains(text(),"Settings")]').click() driver.find_element_by_link_text('Domains').click() @@ -199,9 +179,8 @@ def delete_domain(driver, name): '#Domain_table tr > td.dataTables_empty') Functions.fill_element( driver, '//*[@id="Domain_table_filter"]//input', name) - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="Domain_table"]//tr[1]//td[text()="%s"]' % name))) + Functions.step( + driver, '//*[@id="Domain_table"]//tr[1]//td[text()="%s"]' % name) Functions.click_js( - driver, '//*[@id="Domain_table"]//tr[1]//td//a[contains(text(),' - ' "Delete")]') + driver, '//*[@id="Domain_table"]//tr[1]//td//a[contains(text(), "Delete")]') driver.find_element_by_xpath('//*[@id="dataConfirmOK"]').click() diff --git a/t/selenium/functions/Functions.py b/t/selenium/functions/Functions.py index 0f9d08f3..8d901ace 100644 --- a/t/selenium/functions/Functions.py +++ b/t/selenium/functions/Functions.py @@ -1,7 +1,5 @@ -import os from selenium import webdriver from selenium.webdriver.common.keys import Keys -from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By @@ -44,10 +42,16 @@ def create_driver(): def wait_for_loading_screen(driver): + 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(1) for i in range(1, 5): - 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"]'))) + step(driver, xpath, inv=True) driver.implicitly_wait(10) + + +def step(driver, xpath, wait=10, inv=False): + if inv: + ec = EC.invisibility_of_element_located + else: + ec = EC.element_to_be_clickable + WebDriverWait(driver, wait).until(ec((By.XPATH, xpath))) diff --git a/t/selenium/functions/__init__.py b/t/selenium/functions/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/t/selenium/testrun.py b/t/selenium/testrun.py index 49dde11f..8551e1c6 100644 --- a/t/selenium/testrun.py +++ b/t/selenium/testrun.py @@ -4,8 +4,22 @@ import traceback from multiprocessing import Value import nose2 import time -import functions.Collections as Collections -import functions.Functions as Functions + +from functions.Collections import create_customer +from functions.Collections import create_subscriber +from functions.Collections import create_domain +from functions.Collections import delete_customer +from functions.Collections import delete_subscriber +from functions.Collections import delete_domain +from functions.Collections import login_csc +from functions.Collections import login_panel +from functions.Collections import logout_csc +from functions.Functions import click_js +from functions.Functions import create_driver +from functions.Functions import fill_element +from functions.Functions import step +from functions.Functions import wait_for_loading_screen + import selenium.common.exceptions from selenium import webdriver from selenium.webdriver.common.keys import Keys @@ -21,24 +35,23 @@ filename = 0 def preparation(): global customers - driver = Functions.create_driver() - Collections.login_panel(driver) + driver = create_driver() + login_panel(driver) for i in range(0, int(os.environ['THREADS'])): - customers[Collections.create_customer( - driver)] = Collections.create_domain(driver) + customers[create_customer(driver)] = create_domain(driver) del i for customer in customers.keys(): - Collections.create_subscriber(driver, customer, customers[customer]) + create_subscriber(driver, customer, customers[customer]) driver.quit() def cleanup(): global customers - driver = Functions.create_driver() - Collections.login_panel(driver) + driver = create_driver() + login_panel(driver) for customer in customers: - Collections.delete_customer(driver, customer) - Collections.delete_domain(driver, customers[customer]) + delete_customer(driver, customer) + delete_domain(driver, customers[customer]) driver.quit() @@ -47,7 +60,7 @@ class testrun(unittest.TestCase): def setUp(self): global execs global customers - self.driver = Functions.create_driver() + self.driver = create_driver() self.longMessage = True execs.value += 1 key = list(customers.keys())[execs.value % int(os.environ['THREADS'])] @@ -73,17 +86,23 @@ class testrun(unittest.TestCase): "Error Message was not shown") print("OK") print("Try to log in with valid credentials...", end="") - Functions.fill_element( - driver, '//*[@id="csc-login-form"]//div//input[@type=' - '"text"]', "testuser@" + self.domainname) - Functions.fill_element( - driver, '//*[@id="csc-login-form"]//div//input[@type=' - '"password"]', "testpasswd") + fill_element( + driver, + '//*[@id="csc-login-form"]//div//input[@type="text"]', + "testuser@" + self.domainname + ) + fill_element( + driver, + '//*[@id="csc-login-form"]//div//input[@type="password"]', + "testpasswd" + ) driver.find_element_by_xpath( '//*[@id="csc-login"]//div//button').click() - self.assertEqual("testuser", driver.find_element_by_xpath( - '//*[@id="csc-header-toolbar"]//div//span[contains(text(), ' - '"testuser")]').text, "Login failed") + self.assertEqual( + "testuser", + driver.find_element_by_xpath('//*[@id="csc-header-toolbar"]//div//span[contains(text(), "testuser")]').text, + "Login failed" + ) print("OK") print("Try to log out...", end="") driver.find_element_by_xpath( @@ -98,68 +117,46 @@ class testrun(unittest.TestCase): "Change login page language to all avalible languages...", end="") driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/button').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-item q-item-division relative-position q-item-link"]' - ))) - Functions.click_js( - driver, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-collapsible-sub-item relative-position"]/div[2]') + xp = '/html/body/div[@class="q-popover animate-scale"]//div[@class="q-item q-item-division relative-position q-item-link"]' + step(driver, xp) + click_js( + driver, + '/html/body/div[@class="q-popover animate-scale"]//div[@class="q-collapsible-sub-item relative-position"]/div[2]' + ) self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="csc-login"]//div[@class="q-card-title"][contains' - '(text(), "Authentification de l’abonné")]')) > 0, + '//*[@id="csc-login"]//div[@class="q-card-title"][contains(text(), "Authentification de l’abonné")]')) > 0, 'Language was not changed to France') driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/button').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-item q-item-division relative-position q-item-link"]' - ))) - Functions.click_js( - driver, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-collapsible-sub-item relative-position"]/div[3]') + step(driver, xp) + click_js( + driver, '/html/body/div[@class="q-popover animate-scale"]//div[@class="q-collapsible-sub-item relative-position"]/div[3]') self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="csc-login"]//div[@class="q-card-title"][contains' - '(text(), "Accedi come utente")]')) > 0, + '//*[@id="csc-login"]//div[@class="q-card-title"][contains(text(), "Accedi come utente")]')) > 0, 'Language was not changed to Italian') driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/button').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-item q-item-division relative-position q-item-link"]' - ))) - Functions.click_js( - driver, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-collapsible-sub-item relative-position"]/div[4]') + step(driver, xp) + click_js( + driver, '/html/body/div[@class="q-popover animate-scale"]//div[@class="q-collapsible-sub-item relative-position"]/div[4]') self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="csc-login"]//div[@class="q-card-title"][contains' - '(text(), "Iniciar sesión de suscriptor")]')) > 0, + '//*[@id="csc-login"]//div[@class="q-card-title"][contains(text(), "Iniciar sesión de suscriptor")]')) > 0, 'Language was not changed to Spanish') driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/button').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-item q-item-division relative-position q-item-link"]' - ))) - Functions.click_js( - driver, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-collapsible-sub-item relative-position"]/div[5]') + step(driver, xp) + click_js( + driver, '/html/body/div[@class="q-popover animate-scale"]//div[@class="q-collapsible-sub-item relative-position"]/div[5]') self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="csc-login"]//div[@class="q-card-title"][contains' - '(text(), "Subscriber Log-in")]')) > 0, + '//*[@id="csc-login"]//div[@class="q-card-title"][contains(text(), "Subscriber Log-in")]')) > 0, 'Language was not changed to German') driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/button').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-item q-item-division relative-position q-item-link"]' - ))) - Functions.click_js( - driver, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-collapsible-sub-item relative-position"]/div[1]') + step(driver, xp) + click_js( + driver, '/html/body/div[@class="q-popover animate-scale"]//div[@class="q-collapsible-sub-item relative-position"]/div[1]') self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="csc-login"]//div[@class="q-card-title"][contains' - '(text(), "Subscriber Sign In")]')) > 0, + '//*[@id="csc-login"]//div[@class="q-card-title"][contains(text(), "Subscriber Sign In")]')) > 0, 'Language was not changed back to English') print("OK") filename = 0 @@ -170,228 +167,157 @@ class testrun(unittest.TestCase): filename = "test_call_blocking.png" driver = self.driver print("Try to log in with valid credentials...", end="") - Collections.login_csc( - driver, "testuser@" + self.domainname, 'testpasswd') + login_csc(driver, "testuser@" + self.domainname, 'testpasswd') print("OK") print("Go to 'Call Blocking' page...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Call Blocking")]'))) + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Call Blocking")]') driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Call Blocking")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Incoming")]'))) + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Call Blocking")]').click() + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Incoming")]') print("OK") print("Go to 'Incoming'...", end="") driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Incoming")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, ' - '"q-toggle")]'))) + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Incoming")]').click() + step(driver, '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle")]') print("OK") print("Enable 'All anonymous incoming calls are blocked'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, ' - '"q-toggle")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@class="q-item-label"]' - '[contains(text(), "Only incoming calls")]'))) + '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle")]').click() + step(driver, '//*[@id="q-app"]//div[@class="q-item-label"][contains(text(), "Only incoming calls")]') print("OK") - print( - "Enable 'Only incoming calls from listed numbers are allowed'...", - end="") + print("Enable 'Only incoming calls from listed numbers are allowed'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-item-label"]' - '[contains(text(), "Only incoming calls")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div/button[contains(@class, ' - '"q-btn-flat")]/span[contains(@class, "q-btn-inner")]'))) + '//*[@id="q-app"]//div[@class="q-item-label"][contains(text(), "Only incoming calls")]').click() + step(driver, '//*[@id="q-app"]//div/button[contains(@class, "q-btn-flat")]/span[contains(@class, "q-btn-inner")]') print("OK") print("Add a number to incoming call blocks...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div/button[contains(@class, "q-btn-flat")]' - '/span[contains(@class, "q-btn-inner")]').click() + '//*[@id="q-app"]//div/button[contains(@class, "q-btn-flat")]/span[contains(@class, "q-btn-inner")]').click() driver.find_element_by_xpath( '//*[@id="q-app"]//div/input[@type="text"]').send_keys('12345') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="csc-form-actions row justify-center' - '"]/button[2]').click() + '//*[@id="q-app"]//div[@class="csc-form-actions row justify-center"]/button[2]').click() print("OK") print("Check if all settings were properly changed...", end="") self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, ' - '"q-toggle")]/div[contains(@class, "active")]')) > 0, + '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle")]/div[contains(@class, "active")]')) > 0, "Option 'All anonymous incoming calls are blocked' was not " "enabled") self.assertEqual("12345", driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number ' - 'csc-list-item ")]//div[@class="q-item-label"]').text, + '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number csc-list-item ")]//div[@class="q-item-label"]').text, "Number is not correct") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/' - 'div[@class="q-item-"]/button[contains(@class, "q-btn")]'))) + step(driver, '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/div[@class="q-item-"]/button[contains(@class, "q-btn")]') print("OK") print("Edit recently added number...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/' - 'div[@class="q-item-"]/button[contains(@class, "q-btn")]').click() + '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/div[@class="q-item-"]/button[contains(@class, "q-btn")]').click() driver.find_element_by_xpath( - '//div[@class="csc-item-buttons-menu q-list no-border"]' - '/div[1]').click() - Functions.fill_element( - driver, '//*[@id="q-app"]//div/input[@class="col q-input-target' - ' text-left"]', '54321') + '//div[@class="csc-item-buttons-menu q-list no-border"]/div[1]').click() + fill_element( + driver, '//*[@id="q-app"]//div/input[@class="col q-input-target text-left"]', '54321') elem = driver.find_element_by_xpath( '//*[@id="q-app"]//div//i[text()="check"]') driver.execute_script("arguments[0].click();", elem) driver.implicitly_wait(2) - WebDriverWait(driver, 10).until(EC.invisibility_of_element(( - By.XPATH, '//*[@id="q-app"]//div[@class="csc-spinner"]/svg'))) + step(driver, '//*[@id="q-app"]//div[@class="csc-spinner"]/svg', inv=True) driver.implicitly_wait(10) print("OK") print("Check if number was changed properly...", end="") self.assertEqual("54321", driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number ' - 'csc-list-item ")]//div[@class="q-item-label"]').text, + '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number csc-list-item ")]//div[@class="q-item-label"]').text, "Number is not correct") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/' - 'div[@class="q-item-"]/button[contains(@class, "q-btn")]'))) + step(driver, '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/div[@class="q-item-"]/button[contains(@class, "q-btn")]') print("OK") print("Delete number...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/' - 'div[@class="q-item-"]/button[contains(@class, "q-btn")]').click() + '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/div[@class="q-item-"]/button[contains(@class, "q-btn")]').click() driver.find_element_by_xpath( - '//div[@class="csc-item-buttons-menu q-list no-border"]' - '/div[2]').click() + '//div[@class="csc-item-buttons-menu q-list no-border"]/div[2]').click() driver.find_element_by_xpath( - '//div[contains(@class, "csc-dialog-actions")]/button[contains' - '(@class, "text-negative")]').click() + '//div[contains(@class, "csc-dialog-actions")]/button[contains(@class, "text-negative")]').click() self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[@class="csc-list-message"]' - '[contains(text(), "No numbers found")]')) > 0, + '//*[@id="q-app"]//div[@class="csc-list-message"][contains(text(), "No numbers found")]')) > 0, "Number has not been deleted") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Outgoing")]'))) + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Outgoing")]') print("OK") print("Go to 'Outgoing'...", end="") driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Outgoing")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@class="q-item-label"]' - '[contains(text(), "Only outgoing calls")]'))) + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Outgoing")]').click() + step(driver, '//*[@id="q-app"]//div[@class="q-item-label"][contains(text(), "Only outgoing calls")]') print("OK") print( "Enable 'Only outgoing calls from listed numbers are allowed'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-item-label"]' - '[contains(text(), "Only outgoing calls")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div/button[contains(@class, ' - '"q-btn-flat")]/span[contains(@class, "q-btn-inner")]'))) + '//*[@id="q-app"]//div[@class="q-item-label"][contains(text(), "Only outgoing calls")]').click() + step(driver, '//*[@id="q-app"]//div/button[contains(@class, "q-btn-flat")]/span[contains(@class, "q-btn-inner")]') print("OK") print("Add a number to outgoing call blocks...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div/button[contains(@class, "q-btn-flat")]' - '/span[contains(@class, "q-btn-inner")]').click() + '//*[@id="q-app"]//div/button[contains(@class, "q-btn-flat")]/span[contains(@class, "q-btn-inner")]').click() driver.find_element_by_xpath( '//*[@id="q-app"]//div/input[@type="text"]').send_keys('12345') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="csc-form-actions row justify-center' - '"]/button[2]').click() + '//*[@id="q-app"]//div[@class="csc-form-actions row justify-center"]/button[2]').click() print("OK") print("Check if all settings were properly changed...", end="") self.assertEqual("12345", driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number ' - 'csc-list-item ")]//div[@class="q-item-label"]').text, + '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number csc-list-item ")]//div[@class="q-item-label"]').text, "Number is not correct") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/' - 'div[@class="q-item-"]/button[contains(@class, "q-btn")]'))) + step(driver, '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/div[@class="q-item-"]/button[contains(@class, "q-btn")]') print("OK") print("Edit recently added number...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/' - 'div[@class="q-item-"]/button[contains(@class, "q-btn")]').click() + '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/div[@class="q-item-"]/button[contains(@class, "q-btn")]').click() driver.find_element_by_xpath( - '//div[@class="csc-item-buttons-menu q-list no-border"]' - '/div[1]').click() - Functions.fill_element( - driver, '//*[@id="q-app"]//div/input[@class="col q-input-target' - ' text-left"]', '54321') + '//div[@class="csc-item-buttons-menu q-list no-border"]/div[1]').click() + fill_element( + driver, '//*[@id="q-app"]//div/input[@class="col q-input-target text-left"]', '54321') elem = driver.find_element_by_xpath( '//*[@id="q-app"]//div//i[text()="check"]') driver.execute_script("arguments[0].click();", elem) driver.implicitly_wait(2) - WebDriverWait(driver, 10).until(EC.invisibility_of_element_located(( - By.XPATH, '//*[@id="q-app"]//div[@class="csc-spinner"]/svg'))) + step(driver, '//*[@id="q-app"]//div[@class="csc-spinner"]/svg', inv=True) driver.implicitly_wait(10) print("OK") print("Check if number was changed properly...", end="") self.assertEqual("54321", driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number ' - 'csc-list-item ")]//div[@class="q-item-label"]').text, + '//*[@id="q-app"]//div[contains(@class, "csc-blocked-number csc-list-item ")]//div[@class="q-item-label"]').text, "Number is not correct") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/' - 'div[@class="q-item-"]/button[contains(@class, "q-btn")]'))) + step(driver, '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/div[@class="q-item-"]/button[contains(@class, "q-btn")]') print("OK") print("Delete number...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/' - 'div[@class="q-item-"]/button[contains(@class, "q-btn")]').click() + '//*[@id="q-app"]//div[contains(@class, "q-item-side")]/div[@class="q-item-"]/button[contains(@class, "q-btn")]').click() driver.find_element_by_xpath( - '//div[@class="csc-item-buttons-menu q-list no-border"]' - '/div[2]').click() + '//div[@class="csc-item-buttons-menu q-list no-border"]/div[2]').click() driver.find_element_by_xpath( - '//div[contains(@class, "csc-dialog-actions")]/button[contains' - '(@class, "text-negative")]').click() + '//div[contains(@class, "csc-dialog-actions")]/button[contains(@class, "text-negative")]').click() self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[@class="csc-list-message"]' - '[contains(text(), "No numbers found")]')) > 0, + '//*[@id="q-app"]//div[@class="csc-list-message"][contains(text(), "No numbers found")]')) > 0, "Number has not been deleted") driver.implicitly_wait(2) - 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"]'))) - 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"]'))) + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Privacy")]/div[@class="q-inner-loading animate-fade absolute-full column flex-center"]', inv=True) + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Privacy")]/div[@class="q-inner-loading animate-fade absolute-full column flex-center"]', inv=True) driver.implicitly_wait(10) print("OK") print("Go to 'Privacy'...", end="") driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Privacy")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, ' - '"q-toggle")]'))) + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Privacy")]').click() + step(driver, '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle")]') print("OK") print("Enable 'Hide number to callee'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, ' - '"q-toggle")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, ' - '"q-toggle")]'))) + '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle")]').click() + step(driver, '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle")]') print("OK") print("Check if 'Hide number to callee' was enabled...", end="") self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "q-toggle")]//span' - '[contains(text(), "Your number is hidden")]')) > 0, + '//*[@id="q-app"]//div[contains(@class, "q-toggle")]//span[contains(text(), "Your number is hidden")]')) > 0, "Option 'hide number' was not enabled") print("OK") print("Logout...", end="") - Collections.logout_csc(driver) + logout_csc(driver) self.assertEqual( driver.current_url, os.environ['CATALYST_SERVER'] + "/login/subscriber/#/login", "Logout failed") @@ -404,175 +330,126 @@ class testrun(unittest.TestCase): filename = "test_call_forward_after_hours.png" driver = self.driver print("Try to log in with valid credentials...", end="") - Collections.login_csc( - driver, "testuser@" + self.domainname, 'testpasswd') + login_csc(driver, "testuser@" + self.domainname, 'testpasswd') print("OK") print("Go to 'Call Forward' page...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Call Forward")]'))) + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Call Forward")]') driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Call Forward")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "After Hours")]'))) + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Call Forward")]').click() + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "After Hours")]') print("OK") print("Go to 'After Hours'...", end="") driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "After Hours")]').click() + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "After Hours")]').click() time.sleep(1) - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@class="q-alert-actions row ' - 'items-center"]/span[contains(text(), "Add After Hours")]'))) + step(driver, '//*[@id="q-app"]//div[@class="q-alert-actions row items-center"]/span[contains(text(), "Add After Hours")]') print("OK") print("Add After Hours time set...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-alert-actions row items-center"]' - '/span[contains(text(), "Add After Hours")]').click() + '//*[@id="q-app"]//div[@class="q-alert-actions row items-center"]/span[contains(text(), "Add After Hours")]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="csc-add-time-form q-item q-item-' - 'division relative-position"]//div[@class="q-item- row no-wrap"]' - '/div[2]').click() + '//*[@id="q-app"]//div[@class="csc-add-time-form q-item q-item-division relative-position"]//div[@class="q-item- row no-wrap"]/div[2]').click() driver.find_element_by_xpath( - '//div[contains(@class, "q-datetime-clock-circle")]' - '//div[contains(@class, "q-datetime-clock-pos-8")]').click() + '//div[contains(@class, "q-datetime-clock-circle")]//div[contains(@class, "q-datetime-clock-pos-8")]').click() driver.find_element_by_xpath( - '//div[contains(@class, "q-datetime-controls")]' - '/button[3]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@class="csc-add-time-form q-item ' - 'q-item-division relative-position"]//div[@class="q-item- row ' - 'no-wrap"]/div[3]'))) + '//div[contains(@class, "q-datetime-controls")]/button[3]').click() + step(driver, '//*[@id="q-app"]//div[@class="csc-add-time-form q-item q-item-division relative-position"]//div[@class="q-item- row no-wrap"]/div[3]') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="csc-add-time-form q-item q-item-' - 'division relative-position"]//div[@class="q-item- row no-wrap"]' - '/div[3]').click() + '//*[@id="q-app"]//div[@class="csc-add-time-form q-item q-item-division relative-position"]//div[@class="q-item- row no-wrap"]/div[3]').click() driver.find_element_by_xpath( - '//div[contains(@class, "q-datetime-clock-circle")]' - '//div[contains(@class, "q-datetime-clock-pos-16")]').click() + '//div[contains(@class, "q-datetime-clock-circle")]//div[contains(@class, "q-datetime-clock-pos-16")]').click() driver.find_element_by_xpath( - '//div[contains(@class, "q-datetime-controls")]' - '/button[3]').click() + '//div[contains(@class, "q-datetime-controls")]/button[3]').click() driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="q-item-"]/button[2]').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Add number to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[1]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Destination")]/..' - '/input').send_keys('testdestination') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/' - '../input', "100") + '//*[@id="q-app"]//div[contains(text(), "Destination")]/../input').send_keys('testdestination') + fill_element( + driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/../input', "100") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="add-destination-form"]/div/' - 'button[2]').click() - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="add-destination-form"]/div/button[2]').click() + wait_for_loading_screen(driver) print("OK") print("Add voicemail to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[2]').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Add number to 'When im busy'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[1]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Destination")]/..' - '/input').send_keys('testdestination') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/' - '../input', "200") + '//*[@id="q-app"]//div[contains(text(), "Destination")]/../input').send_keys('testdestination') + fill_element( + driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/../input', "200") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="add-destination-form"]/div/' - 'button[2]').click() - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="add-destination-form"]/div/button[2]').click() + wait_for_loading_screen(driver) print("OK") print("Add voicemail to 'When im busy'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[2]').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Enable 'Ring own phone'...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@class="q-field-content col-xs-12' - ' col-sm"]/div[@tabindex="0"]/div[@class="q-option-inner ' - 'relative-position"]'))) - Functions.click_js( + step(driver, '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]/div[@tabindex="0"]/div[@class="q-option-inner relative-position"]') + click_js( driver, - '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]' - '/div[@tabindex="0"]/div[@class="q-option-inner ' - 'relative-position"]') - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]/div[@tabindex="0"]/div[@class="q-option-inner relative-position"]') + wait_for_loading_screen(driver) print("OK") print("Check if all values are correct...", end="") self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle"' - ')]/div[@class="q-option-inner relative-position ' - 'active"]')) > 0, "Option 'Ring own Phone' was not " + '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle")]/div[@class="q-option-inner relative-position active"]')) > 0, "Option 'Ring own Phone' was not " "enabled") self.assertEqual(driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="dest-row own-phone-desktop"]/span' ).text, 'first ring own phone for 15 secs', "Option 'first ring ' " "own Phone for 15 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-' - 'row"]').text, 'then ring testdestination for 100 secs', "Option " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-row"]').text, 'then ring testdestination for 100 secs', "Option " "'Ring testdestination for 100 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-' - 'row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " "im online' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfb"]/div[1]//div[@class="dest-' - 'row"]').text, 'first ring testdestination for 200 secs', "Option " + '//*[@id="q-app"]//div[@groupname="cfb"]/div[1]//div[@class="dest-row"]').text, 'first ring testdestination for 200 secs', "Option " "'Ring testdestination for 200 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfb"]/div[2]//div[@class="dest-' - 'row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " + '//*[@id="q-app"]//div[@groupname="cfb"]/div[2]//div[@class="dest-row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " "im busy' is missing") print("OK") print("Add new source set...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-tab column flex-center ' - 'relative-position icon-and-label"]//span[contains' - '(text(), "Add new")]').click() - Functions.fill_element( - driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' - 'div[1]//input', 'firsttestsourceset') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' - 'div[2]//input', 'firsttestsource') + '//*[@id="q-app"]//div[@class="q-tab column flex-center relative-position icon-and-label"]//span[contains(text(), "Add new")]').click() + fill_element( + driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div[1]//input', 'firsttestsourceset') + fill_element( + driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div[2]//input', 'firsttestsource') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div' - '[@tabindex=0]').click() + '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div[@tabindex=0]').click() driver.find_element_by_xpath( - '/html/body//div[@class="q-popover animate-scale column no-wrap"]' - '/div[2]').click() + '/html/body//div[@class="q-popover animate-scale column no-wrap"]/div[2]').click() driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="q-item-"]/button').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Go to new source set...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div/span[contains' - '(text(), "firsttestsourceset")]').click() + '//*[@id="q-app"]//div/span[contains(text(), "firsttestsourceset")]').click() print("OK") print("Check if source in source set is correct...", end="") self.assertTrue(len(driver.find_elements_by_xpath( @@ -582,13 +459,13 @@ class testrun(unittest.TestCase): print("Add a new source...", end="") driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="sources-section"]/button').click() - Functions.fill_element( + fill_element( driver, '//*[@id="q-app"]//div[@class="add-source-form"]//input', 'newtestsource') driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="add-source-form"]/button[2]' ).click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Check if second source is created properly...", end="") self.assertTrue(len(driver.find_elements_by_xpath( @@ -597,16 +474,13 @@ class testrun(unittest.TestCase): print("OK") print("Delete second source...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "newtestsource")]/../' - 'div[2]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body//div[@class="modal-buttons row"]/' - 'button[2]'))) + '//*[@id="q-app"]//div[contains(text(), "newtestsource")]/../div[2]').click() + step(driver, '/html/body//div[@class="modal-buttons row"]/button[2]') driver.find_element_by_xpath( '/html/body//div[@class="modal-buttons row"]/button[2]').click() print("OK") print("Check if second source was deleted...", end="") - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) self.assertFalse(driver.find_elements_by_xpath( '//*[@id="q-app"]//div[contains(text(), "newtestsource")]'), "Second Source was not deleted") @@ -615,37 +489,30 @@ class testrun(unittest.TestCase): "Try to delete first source and check if error message appears...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "firsttestsource")]/../' - 'div[2]').click() + '//*[@id="q-app"]//div[contains(text(), "firsttestsource")]/../div[2]').click() self.assertTrue(len(driver.find_elements_by_xpath( - '/html/body//div[@class="q-alert row no-wrap shadow-2 ' - 'bg-negative"]')) > 0, "Error Message 'Removing the " + '/html/body//div[@class="q-alert row no-wrap shadow-2 bg-negative"]')) > 0, "Error Message 'Removing the " "last source entry is not allowed' did not appear") print("OK") print("Add number to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[1]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Destination")]/..' - '/input').send_keys('testdestination') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/' - '../input', "100") + '//*[@id="q-app"]//div[contains(text(), "Destination")]/../input').send_keys('testdestination') + fill_element( + driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/../input', "100") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="add-destination-form"]/div/' - 'button[2]').click() - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="add-destination-form"]/div/button[2]').click() + wait_for_loading_screen(driver) print("OK") print("Add voicemail to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[2]').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Check if everyting was added correctly...", end="") self.assertEqual(driver.find_element_by_xpath( @@ -653,23 +520,20 @@ class testrun(unittest.TestCase): ).text, 'do not ring own phone', "Option 'do not ring own phone' " "is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-' - 'row"]').text, 'first ring testdestination for 100 secs', "Option " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-row"]').text, 'first ring testdestination for 100 secs', "Option " "'Ring testdestination for 100 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-' - 'row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " "im online' is missing") print("OK") print("Swap entries in 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]/div[@class="q-item' - '-side q-item-side-right q-item-section dest-btns cursor-pointer"]' + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]/div[@class="q-item-side q-item-side-right q-item-section dest-btns cursor-pointer"]' ).click() driver.find_element_by_xpath( '/html/body/div[@class="q-popover animate-scale"]/div/div[1]' ).click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Check if entries got swapped...", end="") self.assertEqual(driver.find_element_by_xpath( @@ -677,38 +541,27 @@ class testrun(unittest.TestCase): ).text, 'do not ring own phone', "Option 'do not ring own phone' " "is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-' - 'row"]').text, 'first ring Voicebox', "Options did not get swapped" + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-row"]').text, 'first ring Voicebox', "Options did not get swapped" ) print("OK") print("Delete second source set...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="sources-section"]/div/button' - '[@align="right"]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body//div[@class="modal-buttons row"]/' - 'button[2]'))) + '//*[@id="q-app"]//div[@class="sources-section"]/div/button[@align="right"]').click() + step(driver, '/html/body//div[@class="modal-buttons row"]/button[2]') driver.find_element_by_xpath( '/html/body//div[@class="modal-buttons row"]/button[2]').click() 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(( - By.XPATH, '//div[@class="q-loading animate-fade fullscreen column ' - 'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat ' - 'text-white"]'))) + step(driver, '//div[@class="q-loading animate-fade fullscreen column flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat text-white"]', inv=True) + step(driver, '//div[@class="q-loading animate-fade fullscreen column flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat text-white"]', inv=True) driver.implicitly_wait(10) print("OK") print("Check if second source set was deleted...", end="") self.assertFalse(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div/span[contains' - '(text(), "firsttestsourceset")]'), + '//*[@id="q-app"]//div/span[contains(text(), "firsttestsourceset")]'), "Second Source Set was not deleted") print("OK") print("Logout...", end="") - Collections.logout_csc(driver) + logout_csc(driver) self.assertEqual( driver.current_url, os.environ['CATALYST_SERVER'] + "/login/subscriber/#/login", "Logout failed") @@ -721,149 +574,108 @@ class testrun(unittest.TestCase): filename = "test_call_forward_always.png" driver = self.driver print("Try to log in with valid credentials...", end="") - Collections.login_csc( - driver, "testuser@" + self.domainname, 'testpasswd') + login_csc(driver, "testuser@" + self.domainname, 'testpasswd') print("OK") print("Go to 'Call Forward' page...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Call Forward")]'))) + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Call Forward")]') driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Call Forward")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Always")]'))) + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Call Forward")]').click() + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Always")]') print("OK") print("Go to 'Always'...", end="") driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Always")]').click() + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Always")]').click() 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(( - By.XPATH, '//div[@class="q-loading animate-fade fullscreen column ' - 'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat ' - 'text-white"]'))) + step(driver, '//div[@class="q-loading animate-fade fullscreen column flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat text-white"]', inv=True) + step(driver, '//div[@class="q-loading animate-fade fullscreen column flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat text-white"]', inv=True) driver.implicitly_wait(10) print("OK") print("Add number to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[1]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Destination")]/..' - '/input').send_keys('testdestination') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/' - '../input', "100") + '//*[@id="q-app"]//div[contains(text(), "Destination")]/../input').send_keys('testdestination') + fill_element( + driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/../input', "100") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="add-destination-form"]/div/' - 'button[2]').click() - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="add-destination-form"]/div/button[2]').click() + wait_for_loading_screen(driver) print("OK") print("Add voicemail to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[2]').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Add number to 'When im busy'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[1]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Destination")]/..' - '/input').send_keys('testdestination') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/' - '../input', "200") + '//*[@id="q-app"]//div[contains(text(), "Destination")]/../input').send_keys('testdestination') + fill_element( + driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/../input', "200") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="add-destination-form"]/div/' - 'button[2]').click() - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="add-destination-form"]/div/button[2]').click() + wait_for_loading_screen(driver) print("OK") print("Add voicemail to 'When im busy'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[2]').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Enable 'Ring own phone'...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@class="q-field-content col-xs-12' - ' col-sm"]/div[@tabindex="0"]/div[@class="q-option-inner ' - 'relative-position"]'))) - Functions.click_js( + step(driver, '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]/div[@tabindex="0"]/div[@class="q-option-inner relative-position"]') + click_js( driver, - '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]' - '/div[@tabindex="0"]/div[@class="q-option-inner ' - 'relative-position"]') - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]/div[@tabindex="0"]/div[@class="q-option-inner relative-position"]') + wait_for_loading_screen(driver) print("OK") print("Check if all values are correct...", end="") self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle"' - ')]/div[@class="q-option-inner relative-position ' - 'active"]')) > 0, "Option 'Ring own Phone' was not " + '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle")]/div[@class="q-option-inner relative-position active"]')) > 0, "Option 'Ring own Phone' was not " "enabled") self.assertEqual(driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="dest-row own-phone-desktop"]/span' ).text, 'first ring own phone for 15 secs', "Option 'first ring ' " "own Phone for 15 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-' - 'row"]').text, 'then ring testdestination for 100 secs', "Option " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-row"]').text, 'then ring testdestination for 100 secs', "Option " "'Ring testdestination for 100 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-' - 'row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " "im online' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfb"]/div[1]//div[@class="dest-' - 'row"]').text, 'first ring testdestination for 200 secs', "Option " + '//*[@id="q-app"]//div[@groupname="cfb"]/div[1]//div[@class="dest-row"]').text, 'first ring testdestination for 200 secs', "Option " "'Ring testdestination for 200 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfb"]/div[2]//div[@class="dest-' - 'row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " + '//*[@id="q-app"]//div[@groupname="cfb"]/div[2]//div[@class="dest-row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " "im busy' is missing") print("OK") print("Add new source set...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-tab column flex-center ' - 'relative-position icon-and-label"]//span[contains' - '(text(), "Add new")]').click() - Functions.fill_element( - driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' - 'div[1]//input', 'secondtestsourceset') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' - 'div[2]//input', 'secondtestsource') + '//*[@id="q-app"]//div[@class="q-tab column flex-center relative-position icon-and-label"]//span[contains(text(), "Add new")]').click() + fill_element( + driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div[1]//input', 'secondtestsourceset') + fill_element( + driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div[2]//input', 'secondtestsource') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div' - '[@tabindex=0]').click() + '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div[@tabindex=0]').click() driver.find_element_by_xpath( - '/html/body//div[@class="q-popover animate-scale column no-wrap"]' - '/div[2]').click() + '/html/body//div[@class="q-popover animate-scale column no-wrap"]/div[2]').click() driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="q-item-"]/button').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Go to new source set...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div/span[contains' - '(text(), "secondtestsourceset")]').click() + '//*[@id="q-app"]//div/span[contains(text(), "secondtestsourceset")]').click() print("OK") print("Check if source in source set is correct...", end="") self.assertTrue(len(driver.find_elements_by_xpath( @@ -873,13 +685,13 @@ class testrun(unittest.TestCase): print("Add a new source...", end="") driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="sources-section"]/button').click() - Functions.fill_element( + fill_element( driver, '//*[@id="q-app"]//div[@class="add-source-form"]//input', 'newtestsource') driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="add-source-form"]/button[2]' ).click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Check if second source is created properly...", end="") self.assertTrue(len(driver.find_elements_by_xpath( @@ -888,16 +700,13 @@ class testrun(unittest.TestCase): print("OK") print("Delete second source...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "newtestsource")]/../' - 'div[2]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body//div[@class="modal-buttons row"]/' - 'button[2]'))) + '//*[@id="q-app"]//div[contains(text(), "newtestsource")]/../div[2]').click() + step(driver, '/html/body//div[@class="modal-buttons row"]/button[2]') driver.find_element_by_xpath( '/html/body//div[@class="modal-buttons row"]/button[2]').click() print("OK") print("Check if second source was deleted...", end="") - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) self.assertFalse(driver.find_elements_by_xpath( '//*[@id="q-app"]//div[contains(text(), "newtestsource")]'), "Second Source was not deleted") @@ -906,37 +715,30 @@ class testrun(unittest.TestCase): "Try to delete first source and check if error message appears...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "secondtestsource")]/../' - 'div[2]').click() + '//*[@id="q-app"]//div[contains(text(), "secondtestsource")]/../div[2]').click() self.assertTrue(len(driver.find_elements_by_xpath( - '/html/body//div[@class="q-alert row no-wrap shadow-2 ' - 'bg-negative"]')) > 0, "Error Message 'Removing the " + '/html/body//div[@class="q-alert row no-wrap shadow-2 bg-negative"]')) > 0, "Error Message 'Removing the " "last source entry is not allowed' did not appear") print("OK") print("Add number to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[1]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Destination")]/..' - '/input').send_keys('testdestination') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/' - '../input', "100") + '//*[@id="q-app"]//div[contains(text(), "Destination")]/../input').send_keys('testdestination') + fill_element( + driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/../input', "100") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="add-destination-form"]/div/' - 'button[2]').click() - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="add-destination-form"]/div/button[2]').click() + wait_for_loading_screen(driver) print("OK") print("Add voicemail to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[2]').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Check if everyting was added correctly...", end="") self.assertEqual(driver.find_element_by_xpath( @@ -944,23 +746,20 @@ class testrun(unittest.TestCase): ).text, 'do not ring own phone', "Option 'do not ring own phone' " "is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-' - 'row"]').text, 'first ring testdestination for 100 secs', "Option " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-row"]').text, 'first ring testdestination for 100 secs', "Option " "'Ring testdestination for 100 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-' - 'row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " "im online' is missing") print("OK") print("Swap entries in 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]/div[@class="q-item' - '-side q-item-side-right q-item-section dest-btns cursor-pointer"]' + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]/div[@class="q-item-side q-item-side-right q-item-section dest-btns cursor-pointer"]' ).click() driver.find_element_by_xpath( '/html/body/div[@class="q-popover animate-scale"]/div/div[1]' ).click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Check if entries got swapped...", end="") self.assertEqual(driver.find_element_by_xpath( @@ -968,38 +767,27 @@ class testrun(unittest.TestCase): ).text, 'do not ring own phone', "Option 'do not ring own phone' " "is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-' - 'row"]').text, 'first ring Voicebox', "Options did not get swapped" + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-row"]').text, 'first ring Voicebox', "Options did not get swapped" ) print("OK") print("Delete second source set...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="sources-section"]/div/button' - '[@align="right"]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body//div[@class="modal-buttons row"]/' - 'button[2]'))) + '//*[@id="q-app"]//div[@class="sources-section"]/div/button[@align="right"]').click() + step(driver, '/html/body//div[@class="modal-buttons row"]/button[2]') driver.find_element_by_xpath( '/html/body//div[@class="modal-buttons row"]/button[2]').click() 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(( - By.XPATH, '//div[@class="q-loading animate-fade fullscreen column ' - 'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat ' - 'text-white"]'))) + step(driver, '//div[@class="q-loading animate-fade fullscreen column flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat text-white"]', inv=True) + step(driver, '//div[@class="q-loading animate-fade fullscreen column flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat text-white"]', inv=True) driver.implicitly_wait(10) print("OK") print("Check if second source set was deleted...", end="") self.assertFalse(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div/span[contains' - '(text(), "secondtestsourceset")]'), + '//*[@id="q-app"]//div/span[contains(text(), "secondtestsourceset")]'), "Second Source Set was not deleted") print("OK") print("Logout...", end="") - Collections.logout_csc(driver) + logout_csc(driver) self.assertEqual( driver.current_url, os.environ['CATALYST_SERVER'] + "/login/subscriber/#/login", "Logout failed") @@ -1012,175 +800,126 @@ class testrun(unittest.TestCase): filename = "test_call_forward_company_hours.png" driver = self.driver print("Try to log in with valid credentials...", end="") - Collections.login_csc( - driver, "testuser@" + self.domainname, 'testpasswd') + login_csc(driver, "testuser@" + self.domainname, 'testpasswd') print("OK") print("Go to 'Call Forward' page...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Call Forward")]'))) + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Call Forward")]') driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Call Forward")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Company Hours")]'))) + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Call Forward")]').click() + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Company Hours")]') print("OK") print("Go to 'Company Hours'...", end="") driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Company Hours")]').click() + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Company Hours")]').click() time.sleep(1) - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@class="q-alert-actions row ' - 'items-center"]/span[contains(text(), "Add Company Hours")]'))) + step(driver, '//*[@id="q-app"]//div[@class="q-alert-actions row items-center"]/span[contains(text(), "Add Company Hours")]') print("OK") print("Add Company Hours time set...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-alert-actions row items-center"]' - '/span[contains(text(), "Add Company Hours")]').click() + '//*[@id="q-app"]//div[@class="q-alert-actions row items-center"]/span[contains(text(), "Add Company Hours")]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="csc-add-time-form q-item q-item-' - 'division relative-position"]//div[@class="q-item- row no-wrap"]' - '/div[2]').click() + '//*[@id="q-app"]//div[@class="csc-add-time-form q-item q-item-division relative-position"]//div[@class="q-item- row no-wrap"]/div[2]').click() driver.find_element_by_xpath( - '//div[contains(@class, "q-datetime-clock-circle")]' - '//div[contains(@class, "q-datetime-clock-pos-8")]').click() + '//div[contains(@class, "q-datetime-clock-circle")]//div[contains(@class, "q-datetime-clock-pos-8")]').click() driver.find_element_by_xpath( - '//div[contains(@class, "q-datetime-controls")]' - '/button[3]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@class="csc-add-time-form q-item ' - 'q-item-division relative-position"]//div[@class="q-item- row ' - 'no-wrap"]/div[3]'))) + '//div[contains(@class, "q-datetime-controls")]/button[3]').click() + step(driver, '//*[@id="q-app"]//div[@class="csc-add-time-form q-item q-item-division relative-position"]//div[@class="q-item- row no-wrap"]/div[3]') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="csc-add-time-form q-item q-item-' - 'division relative-position"]//div[@class="q-item- row no-wrap"]' - '/div[3]').click() + '//*[@id="q-app"]//div[@class="csc-add-time-form q-item q-item-division relative-position"]//div[@class="q-item- row no-wrap"]/div[3]').click() driver.find_element_by_xpath( - '//div[contains(@class, "q-datetime-clock-circle")]' - '//div[contains(@class, "q-datetime-clock-pos-16")]').click() + '//div[contains(@class, "q-datetime-clock-circle")]//div[contains(@class, "q-datetime-clock-pos-16")]').click() driver.find_element_by_xpath( - '//div[contains(@class, "q-datetime-controls")]' - '/button[3]').click() + '//div[contains(@class, "q-datetime-controls")]/button[3]').click() driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="q-item-"]/button[2]').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Add number to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[1]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Destination")]/..' - '/input').send_keys('testdestination') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/' - '../input', "100") + '//*[@id="q-app"]//div[contains(text(), "Destination")]/../input').send_keys('testdestination') + fill_element( + driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/../input', "100") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="add-destination-form"]/div/' - 'button[2]').click() - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="add-destination-form"]/div/button[2]').click() + wait_for_loading_screen(driver) print("OK") print("Add voicemail to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[2]').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Add number to 'When im busy'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[1]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Destination")]/..' - '/input').send_keys('testdestination') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/' - '../input', "200") + '//*[@id="q-app"]//div[contains(text(), "Destination")]/../input').send_keys('testdestination') + fill_element( + driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/../input', "200") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="add-destination-form"]/div/' - 'button[2]').click() - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="add-destination-form"]/div/button[2]').click() + wait_for_loading_screen(driver) print("OK") print("Add voicemail to 'When im busy'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[2]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[2]').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Enable 'Ring own phone'...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@class="q-field-content col-xs-12' - ' col-sm"]/div[@tabindex="0"]/div[@class="q-option-inner ' - 'relative-position"]'))) - Functions.click_js( + step(driver, '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]/div[@tabindex="0"]/div[@class="q-option-inner relative-position"]') + click_js( driver, - '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]' - '/div[@tabindex="0"]/div[@class="q-option-inner ' - 'relative-position"]') - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="q-field-content col-xs-12 col-sm"]/div[@tabindex="0"]/div[@class="q-option-inner relative-position"]') + wait_for_loading_screen(driver) print("OK") print("Check if all values are correct...", end="") self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle"' - ')]/div[@class="q-option-inner relative-position ' - 'active"]')) > 0, "Option 'Ring own Phone' was not " + '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle")]/div[@class="q-option-inner relative-position active"]')) > 0, "Option 'Ring own Phone' was not " "enabled") self.assertEqual(driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="dest-row own-phone-desktop"]/span' ).text, 'first ring own phone for 15 secs', "Option 'first ring ' " "own Phone for 15 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-' - 'row"]').text, 'then ring testdestination for 100 secs', "Option " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-row"]').text, 'then ring testdestination for 100 secs', "Option " "'Ring testdestination for 100 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-' - 'row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " "im online' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfb"]/div[1]//div[@class="dest-' - 'row"]').text, 'first ring testdestination for 200 secs', "Option " + '//*[@id="q-app"]//div[@groupname="cfb"]/div[1]//div[@class="dest-row"]').text, 'first ring testdestination for 200 secs', "Option " "'Ring testdestination for 200 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfb"]/div[2]//div[@class="dest-' - 'row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " + '//*[@id="q-app"]//div[@groupname="cfb"]/div[2]//div[@class="dest-row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " "im busy' is missing") print("OK") print("Add new source set...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-tab column flex-center ' - 'relative-position icon-and-label"]//span[contains' - '(text(), "Add new")]').click() - Functions.fill_element( - driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' - 'div[1]//input', 'thirdtestsourceset') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/' - 'div[2]//input', 'thirdtestsource') + '//*[@id="q-app"]//div[@class="q-tab column flex-center relative-position icon-and-label"]//span[contains(text(), "Add new")]').click() + fill_element( + driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div[1]//input', 'thirdtestsourceset') + fill_element( + driver, '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div[2]//input', 'thirdtestsource') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div' - '[@tabindex=0]').click() + '//*[@id="q-app"]//div[@class="q-item- row no-wrap"]/div[@tabindex=0]').click() driver.find_element_by_xpath( - '/html/body//div[@class="q-popover animate-scale column no-wrap"]' - '/div[2]').click() + '/html/body//div[@class="q-popover animate-scale column no-wrap"]/div[2]').click() driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="q-item-"]/button').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Go to new source set...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div/span[contains' - '(text(), "thirdtestsourceset")]').click() + '//*[@id="q-app"]//div/span[contains(text(), "thirdtestsourceset")]').click() print("OK") print("Check if source in source set is correct...", end="") self.assertTrue(len(driver.find_elements_by_xpath( @@ -1190,13 +929,13 @@ class testrun(unittest.TestCase): print("Add a new source...", end="") driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="sources-section"]/button').click() - Functions.fill_element( + fill_element( driver, '//*[@id="q-app"]//div[@class="add-source-form"]//input', 'newtestsource') driver.find_element_by_xpath( '//*[@id="q-app"]//div[@class="add-source-form"]/button[2]' ).click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Check if second source is created properly...", end="") self.assertTrue(len(driver.find_elements_by_xpath( @@ -1205,16 +944,13 @@ class testrun(unittest.TestCase): print("OK") print("Delete second source...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "newtestsource")]/../' - 'div[2]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body//div[@class="modal-buttons row"]/' - 'button[2]'))) + '//*[@id="q-app"]//div[contains(text(), "newtestsource")]/../div[2]').click() + step(driver, '/html/body//div[@class="modal-buttons row"]/button[2]') driver.find_element_by_xpath( '/html/body//div[@class="modal-buttons row"]/button[2]').click() print("OK") print("Check if second source was deleted...", end="") - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) self.assertFalse(driver.find_elements_by_xpath( '//*[@id="q-app"]//div[contains(text(), "newtestsource")]'), "Second Source was not deleted") @@ -1223,37 +959,30 @@ class testrun(unittest.TestCase): "Try to delete first source and check if error message appears...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "thirdtestsource")]/../' - 'div[2]').click() + '//*[@id="q-app"]//div[contains(text(), "thirdtestsource")]/../div[2]').click() self.assertTrue(len(driver.find_elements_by_xpath( - '/html/body//div[@class="q-alert row no-wrap shadow-2 ' - 'bg-negative"]')) > 0, "Error Message 'Removing the " + '/html/body//div[@class="q-alert row no-wrap shadow-2 bg-negative"]')) > 0, "Error Message 'Removing the " "last source entry is not allowed' did not appear") print("OK") print("Add number to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[1]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Destination")]/..' - '/input').send_keys('testdestination') - Functions.fill_element( - driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/' - '../input', "100") + '//*[@id="q-app"]//div[contains(text(), "Destination")]/../input').send_keys('testdestination') + fill_element( + driver, '//*[@id="q-app"]//div[contains(text(), "Timeout")]/../input', "100") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="add-destination-form"]/div/' - 'button[2]').click() - Functions.wait_for_loading_screen(driver) + '//*[@id="q-app"]//div[@class="add-destination-form"]/div/button[2]').click() + wait_for_loading_screen(driver) print("OK") print("Add voicemail to 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div' - '[@class="add-destination-form"]/button').click() + '//*[@id="q-app"]//div[@class="dest-card"]/div[1]/div[@class="add-destination-form"]/button').click() driver.find_element_by_xpath( '//div[@class="q-popover animate-scale"]/div/div[2]').click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Check if everyting was added correctly...", end="") self.assertEqual(driver.find_element_by_xpath( @@ -1261,23 +990,20 @@ class testrun(unittest.TestCase): ).text, 'do not ring own phone', "Option 'do not ring own phone' " "is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-' - 'row"]').text, 'first ring testdestination for 100 secs', "Option " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-row"]').text, 'first ring testdestination for 100 secs', "Option " "'Ring testdestination for 100 secs' is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-' - 'row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " + '//*[@id="q-app"]//div[@groupname="cfu"]/div[2]//div[@class="dest-row"]').text, 'then ring Voicebox', "Option 'Ring Voicebox when " "im online' is missing") print("OK") print("Swap entries in 'When im online'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]/div[@class="q-item' - '-side q-item-side-right q-item-section dest-btns cursor-pointer"]' + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]/div[@class="q-item-side q-item-side-right q-item-section dest-btns cursor-pointer"]' ).click() driver.find_element_by_xpath( '/html/body/div[@class="q-popover animate-scale"]/div/div[1]' ).click() - Functions.wait_for_loading_screen(driver) + wait_for_loading_screen(driver) print("OK") print("Check if entries got swapped...", end="") self.assertEqual(driver.find_element_by_xpath( @@ -1285,38 +1011,27 @@ class testrun(unittest.TestCase): ).text, 'do not ring own phone', "Option 'do not ring own phone' " "is missing") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-' - 'row"]').text, 'first ring Voicebox', "Options did not get swapped" + '//*[@id="q-app"]//div[@groupname="cfu"]/div[1]//div[@class="dest-row"]').text, 'first ring Voicebox', "Options did not get swapped" ) print("OK") print("Delete second source set...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="sources-section"]/div/button' - '[@align="right"]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body//div[@class="modal-buttons row"]/' - 'button[2]'))) + '//*[@id="q-app"]//div[@class="sources-section"]/div/button[@align="right"]').click() + step(driver, '/html/body//div[@class="modal-buttons row"]/button[2]') driver.find_element_by_xpath( '/html/body//div[@class="modal-buttons row"]/button[2]').click() 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(( - By.XPATH, '//div[@class="q-loading animate-fade fullscreen column ' - 'flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat ' - 'text-white"]'))) + step(driver, '//div[@class="q-loading animate-fade fullscreen column flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat text-white"]', inv=True) + step(driver, '//div[@class="q-loading animate-fade fullscreen column flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat text-white"]', inv=True) driver.implicitly_wait(10) print("OK") print("Check if second source set was deleted...", end="") self.assertFalse(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div/span[contains' - '(text(), "thirdtestsourceset")]'), + '//*[@id="q-app"]//div/span[contains(text(), "thirdtestsourceset")]'), "Second Source Set was not deleted") print("OK") print("Logout...", end="") - Collections.logout_csc(driver) + logout_csc(driver) self.assertEqual( driver.current_url, os.environ['CATALYST_SERVER'] + "/login/subscriber/#/login", "Logout failed") @@ -1329,16 +1044,12 @@ class testrun(unittest.TestCase): filename = "test_conference_conversations.png" driver = self.driver print("Try to log in with valid credentials...", end="") - Collections.login_csc( - driver, "testuser@" + self.domainname, 'testpasswd') + login_csc(driver, "testuser@" + self.domainname, 'testpasswd') print("OK") print("Check out 'Join Conference' screen...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Join conference")]'))) + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Join conference")]') driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Join conference")]').click() + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Join conference")]').click() # --------Disabled. Active RTC:Engine required for these tests-------- # driver.find_element_by_xpath( # '//*[@id="csc-conf-link-input"]/div/input').send_keys( @@ -1357,42 +1068,30 @@ class testrun(unittest.TestCase): '//*[@id="csc-conf-header"]/div/button').click() print("OK") print("Go to 'Conversations' page...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Conversations")]'))) + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Conversations")]') driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Conversations")]').click() + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Conversations")]').click() print("OK") print("Check if all sections are empty...", end="") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="csc-conversation-content"]/div[@class="row justify-' - 'center csc-conversation-list-message"]').text, 'No Calls, ' - 'Voicemails or Faxes found', "Section 'All' is not empty") + '//*[@id="csc-conversation-content"]/div[@class="row justify-center csc-conversation-list-message"]').text, 'No Calls, Voicemails or Faxes found', "Section 'All' is not empty") driver.find_element_by_xpath( - '//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller ' - 'row no-wrap"]//span[contains(text(), "Calls")]').click() + '//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller row no-wrap"]//span[contains(text(), "Calls")]').click() self.assertEqual(driver.find_element_by_xpath( - '//*[@id="csc-conversation-content"]/div[@class="row justify-' - 'center csc-conversation-list-message"]').text, 'No Calls found', + '//*[@id="csc-conversation-content"]/div[@class="row justify-center csc-conversation-list-message"]').text, 'No Calls found', "Section 'Calls' is notempty") driver.find_element_by_xpath( - '//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller ' - 'row no-wrap"]//span[contains(text(), "Faxes")]').click() + '//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller row no-wrap"]//span[contains(text(), "Faxes")]').click() self.assertEqual(driver.find_element_by_xpath( - '//*[@id="csc-conversation-content"]/div[@class="row justify-' - 'center csc-conversation-list-message"]').text, 'No Faxes found', + '//*[@id="csc-conversation-content"]/div[@class="row justify-center csc-conversation-list-message"]').text, 'No Faxes found', "Section 'Faxes' is not empty") driver.find_element_by_xpath( - '//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller ' - 'row no-wrap"]//span[contains(text(), "Voicemails")]').click() + '//*[@id="csc-conversations-tabs"]//div[@class="q-tabs-scroller row no-wrap"]//span[contains(text(), "Voicemails")]').click() self.assertEqual(driver.find_element_by_xpath( - '//*[@id="csc-conversation-content"]/div[@class="row justify-' - 'center csc-conversation-list-message"]').text, 'No Voicemails ' - 'found', "Section 'Voicemails' is not empty") + '//*[@id="csc-conversation-content"]/div[@class="row justify-center csc-conversation-list-message"]').text, 'No Voicemails found', "Section 'Voicemails' is not empty") print("OK") print("Logout...", end="") - Collections.logout_csc(driver) + logout_csc(driver) self.assertEqual( driver.current_url, os.environ['CATALYST_SERVER'] + "/login/subscriber/#/login", "Logout failed") @@ -1405,70 +1104,50 @@ class testrun(unittest.TestCase): filename = "test_reminder.png" driver = self.driver print("Try to log in with valid credentials...", end="") - Collections.login_csc( - driver, "testuser@" + self.domainname, 'testpasswd') + login_csc(driver, "testuser@" + self.domainname, 'testpasswd') print("OK") print("Go to 'Reminder' page...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Reminder")]'))) + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Reminder")]') driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Reminder")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, ' - '"q-toggle")]//span[contains(text(), "Reminder")]'))) + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Reminder")]').click() + step(driver, '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle")]//span[contains(text(), "Reminder")]') print("OK") print("Enable reminders...", end="") time.sleep(1) driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle"' - ')]//span[contains(text(), "Reminder")]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[contains(@class, ' - '"q-input-target justify-start")]'))) + '//*[@id="q-app"]//div[@tabindex="0"][contains(@class, "q-toggle")]//span[contains(text(), "Reminder")]').click() + step(driver, '//*[@id="q-app"]//div[contains(@class, "q-input-target justify-start")]') time.sleep(1) print("OK") print("Set time for reminder...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains' - '(@class, "q-input-target justify-start")]').click() + '//*[@id="q-app"]//div[contains(@class, "q-input-target justify-start")]').click() driver.find_element_by_xpath( - '//div[contains(@class, "q-datetime-clock-circle")]' - '//div[contains(@class, "q-datetime-clock-pos-13")]').click() + '//div[contains(@class, "q-datetime-clock-circle")]//div[contains(@class, "q-datetime-clock-pos-13")]').click() driver.find_element_by_xpath( - '//div[contains(@class, "q-datetime-clock-circle")]' - '//div[contains(@class, "q-datetime-clock-pos-7")]').click() + '//div[contains(@class, "q-datetime-clock-circle")]//div[contains(@class, "q-datetime-clock-pos-7")]').click() driver.find_element_by_xpath( - '//div[contains(@class, "q-datetime-controls")]' - '/button[2]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[@tabindex="0"]/span' - '[@class="q-option-label"][contains(text(), "Always")]'))) + '//div[contains(@class, "q-datetime-controls")]/button[2]').click() + step(driver, '//*[@id="q-app"]//div[@tabindex="0"]/span[@class="q-option-label"][contains(text(), "Always")]') time.sleep(1) print("OK") print("Set reminder to 'Always'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@tabindex="0"]//span' - '[contains(text(), "Always")]').click() + '//*[@id="q-app"]//div[@tabindex="0"]//span[contains(text(), "Always")]').click() print("OK") print("Check if reminder settings were applied correctly...", end="") self.assertEqual('Reminder is enabled', driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@tabindex="0"]//' - 'span[contains(text(), "Reminder")]').text, + '//*[@id="q-app"]//div[@tabindex="0"]//span[contains(text(), "Reminder")]').text, "Reminder is not enabled") self.assertEqual('13:35', driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains' - '(@class, "q-input-target justify-start")]').text, + '//*[@id="q-app"]//div[contains(@class, "q-input-target justify-start")]').text, "Time is not correct") self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[@tabindex="0"]/div' - '[contains(@class, "active")]/../' - 'span[contains(text(), "Always")]')) > 0, + '//*[@id="q-app"]//div[@tabindex="0"]/div[contains(@class, "active")]/../span[contains(text(), "Always")]')) > 0, "Option 'Always' was not selected") print("OK") print("Logout...", end="") - Collections.logout_csc(driver) + logout_csc(driver) self.assertEqual( driver.current_url, os.environ['CATALYST_SERVER'] + "/login/subscriber/#/login", "Logout failed") @@ -1481,77 +1160,46 @@ class testrun(unittest.TestCase): filename = "test_settings.png" driver = self.driver print("Try to log in with valid credentials...", end="") - Collections.login_csc( - driver, "testuser@" + self.domainname, 'testpasswd') - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Reminder")]'))) + login_csc(driver, "testuser@" + self.domainname, 'testpasswd') + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Reminder")]') print("OK") print("Change home page language to all avalible languages...", end="") driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/button').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-item q-item-division relative-position q-item-link"]' - ))) - Functions.click_js( - driver, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-collapsible-sub-item relative-position"]/div[2]') + xp = '/html/body/div[@class="q-popover animate-scale"]//div[@class="q-item q-item-division relative-position q-item-link"]' + click_div = '/html/body/div[@class="q-popover animate-scale"]//div[@class="q-collapsible-sub-item relative-position"]/div[{}]' + step(driver, xp) + click_js(driver, click_div.format(2)) self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Rappel")]')) > 0, + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Rappel")]')) > 0, 'Language was not changed to France') driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/button').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-item q-item-division relative-position q-item-link"]' - ))) - Functions.click_js( - driver, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-collapsible-sub-item relative-position"]/div[3]') + step(driver, xp) + click_js(driver, click_div.format(3)) self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Promemoria")]')) > 0, + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Promemoria")]')) > 0, 'Language was not changed to Italian') driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/button').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-item q-item-division relative-position q-item-link"]' - ))) - Functions.click_js( - driver, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-collapsible-sub-item relative-position"]/div[4]') + step(driver, xp) + click_js(driver, click_div.format(4)) self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Recordatorio")]')) > 0, + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Recordatorio")]')) > 0, 'Language was not changed to Spanish') driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/button').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-item q-item-division relative-position q-item-link"]' - ))) - Functions.click_js( - driver, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-collapsible-sub-item relative-position"]/div[5]') + step(driver, xp) + click_js(driver, click_div.format(5)) self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Erinnerung")]')) > 0, + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Erinnerung")]')) > 0, 'Language was not changed to German') driver.find_element_by_xpath( '//*[@id="csc-header-toolbar"]/button').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-item q-item-division relative-position q-item-link"]' - ))) - Functions.click_js( - driver, '/html/body/div[@class="q-popover animate-scale"]//div' - '[@class="q-collapsible-sub-item relative-position"]/div[1]') + step(driver, xp) + click_js(driver, click_div.format(1)) self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Reminder")]')) > 0, + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Reminder")]')) > 0, 'Language was not changed back to English') print("OK") print("Change user password...", end="") @@ -1560,32 +1208,24 @@ class testrun(unittest.TestCase): driver.find_element_by_xpath( '/html/body//div[contains(text(), "Settings")]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div/button[contains(@class, ' - '"q-btn-rectangle")]').click() + '//*[@id="q-app"]//div/button[contains(@class, "q-btn-rectangle")]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[text() = "New password"]/../' - 'input').send_keys('pass1234') + '//*[@id="q-app"]//div[text() = "New password"]/../input').send_keys('pass1234') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[text() = "New password retyped"]/../' - 'input').send_keys('pass1234') + '//*[@id="q-app"]//div[text() = "New password retyped"]/../input').send_keys('pass1234') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="row justify-center"]/' - 'button[2]').click() + '//*[@id="q-app"]//div[@class="row justify-center"]/button[2]').click() driver.find_element_by_xpath( - '/html/body//div[@class="csc-dialog-actions row justify-end' - ' no-wrap"]/button[2]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="csc-login-form"]//div//input[@type="text"]'))) + '/html/body//div[@class="csc-dialog-actions row justify-end no-wrap"]/button[2]').click() + step(driver, '//*[@id="csc-login-form"]//div//input[@type="text"]') self.assertEqual( driver.current_url, os.environ['CATALYST_SERVER'] + "/login/subscriber/#/login", "Logout failed") print("OK") print("Try to log in with new password...", end="") - Collections.login_csc( - driver, "testuser@" + self.domainname, 'pass1234') + login_csc(driver, "testuser@" + self.domainname, 'pass1234') self.assertEqual("testuser", driver.find_element_by_xpath( - '//*[@id="csc-header-toolbar"]//div//span[contains(text(), ' - '"testuser")]').text, "Login failed") + '//*[@id="csc-header-toolbar"]//div//span[contains(text(), "testuser")]').text, "Login failed") print("OK") print("Change password back to old password...", end="") driver.find_element_by_xpath( @@ -1593,22 +1233,16 @@ class testrun(unittest.TestCase): driver.find_element_by_xpath( '/html/body//div[contains(text(), "Settings")]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div/button[contains(@class, ' - '"q-btn-rectangle")]').click() + '//*[@id="q-app"]//div/button[contains(@class, "q-btn-rectangle")]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div[text() = "New password"]/..' - '/input').send_keys('testpasswd') + '//*[@id="q-app"]//div[text() = "New password"]/../input').send_keys('testpasswd') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[text() = "New password retyped"]/../' - 'input').send_keys('testpasswd') + '//*[@id="q-app"]//div[text() = "New password retyped"]/../input').send_keys('testpasswd') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="row justify-center"]' - '/button[2]').click() + '//*[@id="q-app"]//div[@class="row justify-center"]/button[2]').click() driver.find_element_by_xpath( - '/html/body//div[@class="csc-dialog-actions row justify-end' - ' no-wrap"]/button[2]').click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="csc-login-form"]//div//input[@type="text"]'))) + '/html/body//div[@class="csc-dialog-actions row justify-end no-wrap"]/button[2]').click() + step(driver, '//*[@id="csc-login-form"]//div//input[@type="text"]') self.assertEqual( driver.current_url, os.environ['CATALYST_SERVER'] + "/login/subscriber/#/login", "Logout failed") @@ -1621,92 +1255,69 @@ class testrun(unittest.TestCase): filename = "test_speed_dial.png" driver = self.driver print("Try to log in with valid credentials...", end="") - Collections.login_csc( - driver, "testuser@" + self.domainname, 'testpasswd') - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Speed Dial")]'))) + login_csc(driver, "testuser@" + self.domainname, 'testpasswd') + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Speed Dial")]') print("OK") print("Go to 'Speed Dial'...", end="") driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Speed Dial")]').click() + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Speed Dial")]').click() 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"]'))) + step(driver, '//div[@class="q-loading animate-fade fullscreen column flex-center z-maxundefined"]/svg[@class="q-spinner q-spinner-mat text-white"]', inv=True) driver.implicitly_wait(10) print("OK") print("Add a speed dial...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div//button[contains' - '(@class, "q-btn-rectangle")]').click() + '//*[@id="q-app"]//div//button[contains(@class, "q-btn-rectangle")]').click() driver.find_element_by_xpath( '//*[@id="q-app"]//div[@tabindex="0"]').click() driver.find_element_by_xpath( '//*[@class="no-border scroll q-list q-list-link"]/div[2]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div/input' - '[@class="col q-input-target text-left"]').send_keys("testtext") + '//*[@id="q-app"]//div/input[@class="col q-input-target text-left"]').send_keys("testtext") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="row justify-center form-actions"]' - '/button[contains(@class, "text-primary")]').click() + '//*[@id="q-app"]//div[@class="row justify-center form-actions"]/button[contains(@class, "text-primary")]').click() print("OK") print("Check if speed dial details are correct...", end="") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-item-label"]' - '/span[contains(text(), "When")]') + '//*[@id="q-app"]//div[@class="q-item-label"]/span[contains(text(), "When")]') .text, "When I dial *1 ...", "Speed dial has not been created") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-item-sublabel"]' - '[contains(text(), "ring")]') + '//*[@id="q-app"]//div[@class="q-item-sublabel"][contains(text(), "ring")]') .text, "ring testtext", "Speed dial is not correct") print("OK") print("Add a second speed dial...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div//button[contains' - '(@class, "q-btn-rectangle")]'))) + step(driver, '//*[@id="q-app"]//div//button[contains(@class, "q-btn-rectangle")]') driver.find_element_by_xpath( - '//*[@id="q-app"]//div//button[contains' - '(@class, "q-btn-rectangle")]').click() + '//*[@id="q-app"]//div//button[contains(@class, "q-btn-rectangle")]').click() driver.find_element_by_xpath( '//*[@id="q-app"]//div[@tabindex="0"]').click() driver.find_element_by_xpath( '//*[@class="no-border scroll q-list q-list-link"]/div[2]').click() driver.find_element_by_xpath( - '//*[@id="q-app"]//div/input' - '[@class="col q-input-target text-left"]').send_keys("asdf") + '//*[@id="q-app"]//div/input[@class="col q-input-target text-left"]').send_keys("asdf") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="row justify-center form-actions"]' - '/button[contains(@class, "text-primary")]').click() + '//*[@id="q-app"]//div[@class="row justify-center form-actions"]/button[contains(@class, "text-primary")]').click() print("OK") print("Check if second speed dial details are correct...", end="") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-item-label"]' - '/span[contains(text(), "*2")]') + '//*[@id="q-app"]//div[@class="q-item-label"]/span[contains(text(), "*2")]') .text, "When I dial *2 ...", "Speed dial has not been created") self.assertEqual(driver.find_element_by_xpath( - '//*[@id="q-app"]//div[@class="q-item-sublabel"]' - '[contains(text(), "asdf")]') + '//*[@id="q-app"]//div[@class="q-item-sublabel"][contains(text(), "asdf")]') .text, "ring asdf", "Speed dial is not correct") print("OK") print("Delete all speed dials...", end="") driver.find_element_by_xpath( '//*[@id="q-app"]//div/button[@slot="right"]').click() driver.find_element_by_xpath( - '//div[@class="modal-buttons row"]//button[contains(@class, ' - '"text-negative")]').click() + '//div[@class="modal-buttons row"]//button[contains(@class, "text-negative")]').click() WebDriverWait(driver, 10).until(EC.presence_of_element_located(( - By.XPATH, '//div[@class="q-toast-container active"]//div[contains' - '(text(), "Unassigned slot *1")]'))) - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div/button[@slot="right"]'))) + By.XPATH, '//div[@class="q-toast-container active"]//div[contains(text(), "Unassigned slot *1")]'))) + step(driver, '//*[@id="q-app"]//div/button[@slot="right"]') driver.find_element_by_xpath( '//*[@id="q-app"]//div/button[@slot="right"]').click() driver.find_element_by_xpath( - '//div[@class="modal-buttons row"]//button[contains(@class, ' - '"text-negative")]').click() + '//div[@class="modal-buttons row"]//button[contains(@class, "text-negative")]').click() print("OK") print("Check if speed dials were deleted...", end="") self.assertTrue(len(driver.find_elements_by_xpath( @@ -1714,7 +1325,7 @@ class testrun(unittest.TestCase): ) > 0, "Speed dials was not deleted") print("OK") print("Logout...", end="") - Collections.logout_csc(driver) + logout_csc(driver) self.assertEqual( driver.current_url, os.environ['CATALYST_SERVER'] + "/login/subscriber/#/login", "Logout failed") @@ -1727,62 +1338,45 @@ class testrun(unittest.TestCase): filename = "test_voicebox.png" driver = self.driver print("Try to log in with valid credentials...", end="") - Collections.login_csc( - driver, "testuser@" + self.domainname, 'testpasswd') - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Voicebox")]'))) + login_csc(driver, "testuser@" + self.domainname, 'testpasswd') + step(driver, '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Voicebox")]') print("OK") print("Go to 'Voicebox'...", end="") driver.find_element_by_xpath( - '//*[@id="main-menu"]//div[@class="q-item-label"]' - '[contains(text(), "Voicebox")]').click() + '//*[@id="main-menu"]//div[@class="q-item-label"][contains(text(), "Voicebox")]').click() print("OK") print("Try to enter an invalid voicebox pin...", end="") - WebDriverWait(driver, 10).until(EC.element_to_be_clickable(( - By.XPATH, '//*[@id="q-app"]//div[contains(text(), "Change PIN")]' - '/../input'))) + step(driver, '//*[@id="q-app"]//div[contains(text(), "Change PIN")]/../input') driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Change PIN")]/../' - 'input').send_keys("invalid") + '//*[@id="q-app"]//div[contains(text(), "Change PIN")]/../input').send_keys("invalid") self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[@class="q-field-error col"' - ']')) > 0, "Invalid PIN was not detected") + '//*[@id="q-app"]//div[@class="q-field-error col"]')) > 0, "Invalid PIN was not detected") print("OK") print("Enter valid voicebox pin...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Change PIN")]/../../' - 'i[1]').click() - Functions.fill_element( - driver, '//*[@id="q-app"]//div[contains(text(), "Change PIN")]/../' - 'input', "12345") + '//*[@id="q-app"]//div[contains(text(), "Change PIN")]/../../i[1]').click() + fill_element( + driver, '//*[@id="q-app"]//div[contains(text(), "Change PIN")]/../input', "12345") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Change PIN")]/../../' - 'i[1]').click() + '//*[@id="q-app"]//div[contains(text(), "Change PIN")]/../../i[1]').click() print("OK") print("Try to enter an invalid voicebox email...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Change Email")]/../' - 'input').send_keys("invalid") + '//*[@id="q-app"]//div[contains(text(), "Change Email")]/../input').send_keys("invalid") self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[@class="q-field-error col"' - ']')) > 0, "Invalid Email was not detected") + '//*[@id="q-app"]//div[@class="q-field-error col"]')) > 0, "Invalid Email was not detected") print("OK") print("Enter valid voicebox email...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Change Email")]/../../' - 'i[1]').click() - Functions.fill_element( - driver, '//*[@id="q-app"]//div[contains(text(), "Change Email")]' - '/../input', "test@email.com") + '//*[@id="q-app"]//div[contains(text(), "Change Email")]/../../i[1]').click() + fill_element( + driver, '//*[@id="q-app"]//div[contains(text(), "Change Email")]/../input', "test@email.com") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(text(), "Change Email")]/../../' - 'i[1]').click() + '//*[@id="q-app"]//div[contains(text(), "Change Email")]/../../i[1]').click() print("OK") print("Enable 'Delete voicemail after notification'...", end="") driver.find_element_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "q-toggle")]/span[contains' - '(text(), "Delete voicemail")]').click() + '//*[@id="q-app"]//div[contains(@class, "q-toggle")]/span[contains(text(), "Delete voicemail")]').click() print("OK") print("Check if voicebox settings are correct...", end="") self.assertEqual(driver.find_element_by_xpath( @@ -1792,17 +1386,15 @@ class testrun(unittest.TestCase): '//*[@id="q-app"]//div[contains(text(), "Change Email")]/../input') .get_attribute('value'), "test@email.com", "Email is not correct") self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "csc-toggle-enabled")]' - '/span[contains(text(), "Attach voicemail")]')) > 0, + '//*[@id="q-app"]//div[contains(@class, "csc-toggle-enabled")]/span[contains(text(), "Attach voicemail")]')) > 0, "Option 'Attach voicemail to email notification' was not enabled") self.assertTrue(len(driver.find_elements_by_xpath( - '//*[@id="q-app"]//div[contains(@class, "csc-toggle-enabled")]' - '/span[contains(text(), "Delete voicemail")]')) > 0, + '//*[@id="q-app"]//div[contains(@class, "csc-toggle-enabled")]/span[contains(text(), "Delete voicemail")]')) > 0, "Option 'Delete voicemail after email notification is delivered' " "was not enabled") print("OK") print("Logout...", end="") - Collections.logout_csc(driver) + logout_csc(driver) self.assertEqual( driver.current_url, os.environ['CATALYST_SERVER'] + "/login/subscriber/#/login", "Logout failed")