Skip to content

Commit

Permalink
Merge pull request #204 from nodlesh/fix/init-retry
Browse files Browse the repository at this point in the history
BCW - fix retrying initialization if something goes wrong
  • Loading branch information
nodlesh authored Oct 19, 2023
2 parents 1d21cef + 4b04a21 commit efcb4c0
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions aries-mobile-tests/pageobjects/bc_wallet/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ def still_initializing(self):
# Check for something went wrong modal
if self.oops_something_went_wrong_modal.is_displayed():
# Get the main error
error_title = self.oops_something_went_wrong_modal.get_error_title()
main_error = self.oops_something_went_wrong_modal.get_main_error()
# if Timeout error, then raise exception
if self.oops_something_went_wrong_modal.is_timeout_error():
raise Exception(main_error)
raise Exception(f"{error_title}\n{main_error}")
else:
# Otherwise, Show details, and get the details message and raise exception
self.oops_something_went_wrong_modal.select_show_details()
detailed_error = self.oops_something_went_wrong_modal.get_detailed_error()
raise Exception(f"{main_error}\n{detailed_error}")
raise Exception(f"{error_title}\n{main_error}\n{detailed_error}")
try:
self.find_by(self.loading_locator)
return True
Expand All @@ -64,37 +65,43 @@ def wait_until_initialized(self, timeout=100, retry_attempts=3):
self.still_initializing()
except Exception as e:
if "Oops! Something went wrong" in str(e):
logger.error(f"Oops! Something went wrong. {e}")
logger.error(e)
self.oops_something_went_wrong_modal.select_retry()
else:
raise
except Exception as e:
if "Oops! Something went wrong" in str(e):
logger.error(f"Oops! Something went wrong. {e}")
logger.error(e)
self.oops_something_went_wrong_modal.select_retry()
else:
raise
from pageobjects.bc_wallet.home import HomePage
return HomePage(self.driver)

class OopsSomethingWentWrongModal(BasePage):
"""Oops! Something went wrong Modal page object"""

# Locators
on_this_page_text_locator = "Oops! Something went wrong"
error_title_locator = (AppiumBy.ID, "com.ariesbifold:id/HeaderText")
main_error_locator = (AppiumBy.ID, "com.ariesbifold:id/BodyText")
show_details_locator = (AppiumBy.ID, "com.ariesbifold:id/ShowDetails")
detailed_error_locator = (AppiumBy.ID, "com.ariesbifold:id/DetailsText")
detailed_error_locator = (AppiumBy.ID, "com.ariesbifold:id/BodyText")
retry_locator = (AppiumBy.ID, "com.ariesbifold:id/Retry")

def on_this_page(self):
return super().on_this_page(self.on_this_page_text_locator)

#return super().on_this_page(self.on_this_page_text_locator)
return super().on_this_page(self.error_title_locator)

def is_displayed(self):
return self.on_this_page()

def is_timeout_error(self):
return "Timeout" in self.get_main_error()

def get_error_title(self) -> str:
return self.find_by(self.error_title_locator).text

def get_main_error(self) -> str:
return self.find_by(self.main_error_locator).text

Expand All @@ -105,5 +112,5 @@ def get_detailed_error(self) -> str:
return self.find_by(self.detailed_error_locator).text

def select_retry(self):
self.find_by(self.okay_locator, wait_condition=WaitCondition.ELEMENT_TO_BE_CLICKABLE).click()
self.find_by(self.retry_locator, wait_condition=WaitCondition.ELEMENT_TO_BE_CLICKABLE).click()

0 comments on commit efcb4c0

Please sign in to comment.