5 Commits

Author SHA1 Message Date
104eab4e90 Fix activities selector and minor QOL changes
This changes the test_activities_tab test to select the Activities
tab by label instead of by a fixed id, in addition to providing
support for this sort of selection in the future.

Fixes: #11
2021-11-09 10:56:03 -08:00
3bd09a9ef4 Merge branch 'main' of ssh://git.autonomic.zone:2222/autonomic-cooperative/civicrm-update-tester 2021-11-03 16:41:59 +00:00
f228527c65 --dev points to dev now 2021-11-03 16:40:35 +00:00
b91c04774d Merge pull request 'Fix some type hints in civicrm_tester/base.py' (#10) from cas_typehint_fix_2021-11-03 into main
Reviewed-on: #10
2021-11-03 17:33:48 +01:00
58e8890211 Fix some type hints in civicrm_tester/base.py 2021-11-03 09:31:46 -07:00
2 changed files with 16 additions and 7 deletions

View File

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

View File

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