Merge pull request 'Fix activities selector and minor QOL changes' (#12) from cas_activities_20211109 into main

Reviewed-on: #12
This commit is contained in:
Cassowary Rusnov 2021-11-10 19:24:24 +01:00
commit 98ec8e0e3d
2 changed files with 12 additions and 4 deletions

View File

@ -128,6 +128,10 @@ class BaseTester:
self.logout()
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):
"""Alias for browser.find_element_by_id"""
return self.browser.find_element_by_id(*args, **kwargs)
@ -144,6 +148,10 @@ class BaseTester:
"""Alias for using inbuilt wait object for wait.until(EC.element_to_be_clickable)"""
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):
def __init__(self, *args, **kwargs):

View File

@ -14,10 +14,10 @@ class TestActivitiesTab(BaseTester):
def _test(self, cid: str):
self.debug("loading contact page for CID %s" % 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
activities_tab_button = self.find_element_by_id("ui-id-10")
num_element = activities_tab_button.find_element_by_tag_name("em")
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_of_activ = int(num_element.text)
activities_tab_button.click()
table_row_selector = (
@ -65,4 +65,4 @@ class TestActivitiesTab(BaseTester):
cid_na = "42269" # Nigel Addams
#cid_db = "43193" Use to test 100 max limit
cid_tuple = (cid_da, cid_kh, cid_na)
self._test_all(cid_tuple)
self._test_all(cid_tuple)