Compare commits
5 Commits
c7e9b7e0b6
...
cas_activi
Author | SHA1 | Date | |
---|---|---|---|
104eab4e90 | |||
3bd09a9ef4 | |||
f228527c65 | |||
b91c04774d | |||
58e8890211 |
@ -11,6 +11,7 @@ from selenium.webdriver.common.by import By
|
|||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
|
||||||
|
from typing import Tuple, List
|
||||||
|
|
||||||
class BaseTester:
|
class BaseTester:
|
||||||
"""
|
"""
|
||||||
@ -35,7 +36,7 @@ class BaseTester:
|
|||||||
self.user = user
|
self.user = user
|
||||||
self.passwd = passwd
|
self.passwd = passwd
|
||||||
if dev:
|
if dev:
|
||||||
self.base_url = "https://crm.staging.caat.org.uk"
|
self.base_url = "https://crm.dev.caat.org.uk"
|
||||||
else:
|
else:
|
||||||
self.base_url = "https://crm.staging.caat.org.uk"
|
self.base_url = "https://crm.staging.caat.org.uk"
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ class BaseTester:
|
|||||||
def _test(self, *args):
|
def _test(self, *args):
|
||||||
"""Placeholder to be overwritten by overloading classes"""
|
"""Placeholder to be overwritten by overloading classes"""
|
||||||
|
|
||||||
def _test_all(self, test_strings: tuple[str, str, str]):
|
def _test_all(self, test_strings: Tuple[str, str, str]):
|
||||||
"""Loops testing over the given terms"""
|
"""Loops testing over the given terms"""
|
||||||
try:
|
try:
|
||||||
self.login()
|
self.login()
|
||||||
@ -127,6 +128,10 @@ class BaseTester:
|
|||||||
self.logout()
|
self.logout()
|
||||||
self.browser.close()
|
self.browser.close()
|
||||||
|
|
||||||
|
def find_element(self, *args, **kwargs):
|
||||||
|
"""Alias for browser.find_element"""
|
||||||
|
return self.browser.find_element(*args, **kwargs)
|
||||||
|
|
||||||
def find_element_by_id(self, *args, **kwargs):
|
def find_element_by_id(self, *args, **kwargs):
|
||||||
"""Alias for browser.find_element_by_id"""
|
"""Alias for browser.find_element_by_id"""
|
||||||
return self.browser.find_element_by_id(*args, **kwargs)
|
return self.browser.find_element_by_id(*args, **kwargs)
|
||||||
@ -143,6 +148,10 @@ class BaseTester:
|
|||||||
"""Alias for using inbuilt wait object for wait.until(EC.element_to_be_clickable)"""
|
"""Alias for using inbuilt wait object for wait.until(EC.element_to_be_clickable)"""
|
||||||
return self.wait.until(EC.element_to_be_clickable(locator))
|
return self.wait.until(EC.element_to_be_clickable(locator))
|
||||||
|
|
||||||
|
def get_tab_selector(self, tabtitle):
|
||||||
|
"""Return an XPATH string to the tab labelled `tablabel`."""
|
||||||
|
return "//li/a[@title='{label}']/..".format(label=tabtitle)
|
||||||
|
|
||||||
|
|
||||||
class SearchExportTester(BaseTester):
|
class SearchExportTester(BaseTester):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -151,7 +160,7 @@ class SearchExportTester(BaseTester):
|
|||||||
self.contact_selectall_id = "CIVICRM_QFID_ts_all_4"
|
self.contact_selectall_id = "CIVICRM_QFID_ts_all_4"
|
||||||
self.contact_dropdown_id = "select2-chosen-4"
|
self.contact_dropdown_id = "select2-chosen-4"
|
||||||
|
|
||||||
def _get_export_id(self) -> list[str]:
|
def _get_export_id(self) -> List[str]:
|
||||||
"""Parses url to get the param used to ID what search we are currently doing"""
|
"""Parses url to get the param used to ID what search we are currently doing"""
|
||||||
export_page_url = self.browser.current_url
|
export_page_url = self.browser.current_url
|
||||||
parsed = urlparse.urlparse(export_page_url)
|
parsed = urlparse.urlparse(export_page_url)
|
||||||
|
@ -14,10 +14,10 @@ class TestActivitiesTab(BaseTester):
|
|||||||
def _test(self, cid: str):
|
def _test(self, cid: str):
|
||||||
self.debug("loading contact page for CID %s" % cid)
|
self.debug("loading contact page for CID %s" % cid)
|
||||||
self.browser.get(self.contact_page.format(cid))
|
self.browser.get(self.contact_page.format(cid))
|
||||||
self.wait_until_visible((By.ID, "ui-id-10"))
|
self.wait_until_visible((By.XPATH, self.get_tab_selector("Activities")))
|
||||||
# Contact page as loaded
|
# Contact page as loaded
|
||||||
activities_tab_button = self.find_element_by_id("ui-id-10")
|
activities_tab_button = self.find_element(By.XPATH, self.get_tab_selector("Activities"))
|
||||||
num_element = activities_tab_button.find_element_by_tag_name("em")
|
num_element = activities_tab_button.find_element(By.TAG_NAME, "em")
|
||||||
num_of_activ = int(num_element.text)
|
num_of_activ = int(num_element.text)
|
||||||
activities_tab_button.click()
|
activities_tab_button.click()
|
||||||
table_row_selector = (
|
table_row_selector = (
|
||||||
@ -65,4 +65,4 @@ class TestActivitiesTab(BaseTester):
|
|||||||
cid_na = "42269" # Nigel Addams
|
cid_na = "42269" # Nigel Addams
|
||||||
#cid_db = "43193" Use to test 100 max limit
|
#cid_db = "43193" Use to test 100 max limit
|
||||||
cid_tuple = (cid_da, cid_kh, cid_na)
|
cid_tuple = (cid_da, cid_kh, cid_na)
|
||||||
self._test_all(cid_tuple)
|
self._test_all(cid_tuple)
|
||||||
|
Reference in New Issue
Block a user