diff --git a/aries-mobile-tests/pageobjects/basepage.py b/aries-mobile-tests/pageobjects/basepage.py index 5fec85f9..c9610343 100644 --- a/aries-mobile-tests/pageobjects/basepage.py +++ b/aries-mobile-tests/pageobjects/basepage.py @@ -166,7 +166,7 @@ def find_by_classname(self, *locator): # else: # return False - def scroll_to_element(self, locator, direction='down'): + def scroll_to_element(self, locator:str, direction='down'): """ Scroll to the element based on the accessibility id given. """ """ The locator MUST be an accessibility id. """ """ Can give a direction and the direction only applies to iOS. Default is down. """ @@ -185,10 +185,12 @@ def scroll_to_bottom(self): screen_size = self.driver.get_window_size() screen_height = screen_size['height'] + before_source_ios = self.driver.page_source + # Scroll down the page until the bottom is reached while True: if self.current_platform == 'iOS': - before_source_ios = self.driver.page_source + before_root = ET.fromstring(before_source_ios.encode('utf-8')) self.driver.execute_script('mobile: scroll', {'direction': 'down'}) else: # Scroll for android takes an accessibility id, however it will scroll to the bottom looking for that id and if it doesn't exist, @@ -202,10 +204,19 @@ def scroll_to_bottom(self): if self.current_platform == 'iOS': after_source_ios = self.driver.page_source # Parse the hierarchies using an XML parser - root = ET.fromstring(before_source_ios.encode('utf-8')) - new_root = ET.fromstring(after_source_ios.encode('utf-8')) - if ET.tostring(root) == ET.tostring(new_root): - break + after_root = ET.fromstring(after_source_ios.encode('utf-8')) + + before_last_element = self.get_last_ios_element_on_page(before_root) + after_last_element = self.get_last_ios_element_on_page(after_root) + + # Compare the tag_name of the last iOS elements to determine if we have reached the bottom + if before_last_element is not None and after_last_element is not None: + if before_last_element.tag == after_last_element.tag: + break + + # Update the page source for the next iteration + before_source_ios = after_source_ios + else: window_rect = self.driver.get_window_rect() current_scroll_position = window_rect['y'] + screen_height @@ -213,3 +224,11 @@ def scroll_to_bottom(self): # Check if the bottom of the page has been reached if current_scroll_position >= screen_size['height']: break + + def get_last_ios_element_on_page(self, root): + # Helper function to get the last iOS element that is not XCUIElementTypeOther from an XML hierarchy + last_ios_element = None + for element in root.iter(): + if self.current_platform == 'iOS' and element.tag != 'XCUIElementTypeOther' and element.tag != 'XCUIElementTypeWindow': + last_ios_element = element + return last_ios_element \ No newline at end of file diff --git a/aries-mobile-tests/pageobjects/bc_wallet/developer_settings.py b/aries-mobile-tests/pageobjects/bc_wallet/developer_settings.py index 3d152c2d..dfd65063 100644 --- a/aries-mobile-tests/pageobjects/bc_wallet/developer_settings.py +++ b/aries-mobile-tests/pageobjects/bc_wallet/developer_settings.py @@ -12,7 +12,8 @@ class DeveloperSettingsPage(BasePage): # Locators on_this_page_text_locator = "Developer" back_locator = (AppiumBy.ID, "com.ariesbifold:id/Back") - environment_locator = (AppiumBy.ID, "com.ariesbifold:id/environment") + environment_locator_ios = (AppiumBy.ID, "com.ariesbifold:id/environment") + environment_locator = (AppiumBy.ACCESSIBILITY_ID, "Environment") production_locator = (AppiumBy.ID, "com.ariesbifold:id/production") development_locator = (AppiumBy.ID, "com.ariesbifold:id/development") test_locator = (AppiumBy.ID, "com.ariesbifold:id/test") @@ -22,7 +23,10 @@ def on_this_page(self): def select_env(self, env): if self.on_this_page(): - self.find_by(self.environment_locator).click() + if self.current_platform == "iOS": + self.find_by(self.environment_locator_ios).click() + else: + self.find_by(self.environment_locator).click() if env == 'Production': self.find_by(self.production_locator).click() elif env == 'Development': diff --git a/aries-mobile-tests/pageobjects/bc_wallet/settings.py b/aries-mobile-tests/pageobjects/bc_wallet/settings.py index d19d802e..befa2bc0 100644 --- a/aries-mobile-tests/pageobjects/bc_wallet/settings.py +++ b/aries-mobile-tests/pageobjects/bc_wallet/settings.py @@ -34,8 +34,11 @@ def enable_developer_mode(self): if not self.on_this_page(): raise Exception(f"App not on the {type(self)} page") + # if self.current_platform == "iOS": + # self.scroll_to_element(self.version_locator) + # else: self.scroll_to_bottom() - #version_element = self.find_by(self.version_locator) + if self.current_platform == "iOS" and self.driver.capabilities['platformVersion'] <= '15': # Need to find the element py partial text or accessibility id for iOS 14 and lower version_elements = self.driver.find_elements(AppiumBy.XPATH, "//*[contains(@label, '{}')]".format(self.version_partial_aid_locator[1]))