Fix activities selector and minor QOL changes #12

Merged
cas merged 1 commits from cas_activities_20211109 into main 2021-11-10 18:24:25 +00:00
2 changed files with 12 additions and 4 deletions
Showing only changes of commit 104eab4e90 - Show all commits

View File

@ -128,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)
@ -144,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):

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 = (