Skip to content

[DX-3567] test: reset mac app state #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 46 additions & 11 deletions sample/Tests/test/test_mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,52 @@ def test_1_device_code_login(self):
# Wait for unauthenticated screen
self.altdriver.wait_for_current_scene_to_be("UnauthenticatedScene")

# Login
print("Logging in...")
self.setupChrome()
bring_sample_app_to_foreground()
self.altdriver.wait_for_object(By.NAME, "LoginBtn").tap()
self.login()
bring_sample_app_to_foreground()

# Wait for authenticated screen
self.altdriver.wait_for_current_scene_to_be("AuthenticatedScene")
print("Logged in")
for attempt in range(2):
try:
# Check app state
login_button = self.altdriver.find_object(By.NAME, "LoginBtn")
print("Found login button, app is in the correct state")

# Login
print("Logging in...")
self.setupChrome()
bring_sample_app_to_foreground()
login_button.tap()
self.login()
bring_sample_app_to_foreground()

# Wait for authenticated screen
self.altdriver.wait_for_current_scene_to_be("AuthenticatedScene")
print("Logged in")
return
except Exception as err:
if attempt == 0:
# Reset app

# Relogin
print("Try reset the app and log out once...")
self.altdriver.wait_for_object(By.NAME, "ReloginBtn").tap()

# Wait for authenticated screen
self.altdriver.wait_for_current_scene_to_be("AuthenticatedScene")
print("Re-logged in")

# Logout
print("Logging out...")
self.setupChrome()
bring_sample_app_to_foreground()
self.altdriver.find_object(By.NAME, "LogoutBtn").tap()
time.sleep(5)
bring_sample_app_to_foreground()

# Wait for unauthenticated screen
self.altdriver.wait_for_current_scene_to_be("UnauthenticatedScene")
self.seleniumdriver.quit()
print("Logged out and successfully reset app")

time.sleep(5)
else:
raise SystemExit(f"Failed to reset app {err}")

def test_2_other_functions(self):
self.test_0_other_functions()
Expand Down
Loading