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
This commit is contained in:
parent
3bd09a9ef4
commit
104eab4e90
@ -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):
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user