diff --git a/sample/Tests/test/test_ios.py b/sample/Tests/test/test_ios.py index 0ccd9f6ae..050f976ad 100644 --- a/sample/Tests/test/test_ios.py +++ b/sample/Tests/test/test_ios.py @@ -10,15 +10,15 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC -from alttester import AltDriver, By +from alttester import * -from test import TestConfig +from test import TestConfig, UnityTest sys.path.insert(0, str(Path(__file__).resolve().parent.parent / 'src')) from fetch_otp import fetch_code # To run this test on an actual Android device: appium --base-path /wd/hub --allow-insecure chromedriver_autodownload -class TestBase(unittest.TestCase): +class TestBase(UnityTest): altdriver = None appium_driver = None @@ -37,21 +37,12 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): print("\nEnding") - cls.altdriver.stop() cls.appium_driver.quit() + cls.altdriver.stop() - def test_1_pkce_login(self): - # Select use PKCE auth - self.altdriver.find_object(By.NAME, "PKCE").tap() - - # Wait for unauthenticated screen - self.altdriver.wait_for_current_scene_to_be("UnauthenticatedScene") - - # Login - loginBtn = self.altdriver.wait_for_object(By.NAME, "LoginBtn") - loginBtn.tap() - - driver = self.appium_driver + @classmethod + def login(cls): + driver = cls.appium_driver # Wait for the ASWebAuthenticationSession context to appear WebDriverWait(driver, 30).until(lambda d: len(d.contexts) > 2) @@ -90,9 +81,6 @@ def test_1_pkce_login(self): otp_field = driver.find_element(by=AppiumBy.XPATH, value=f"//div[@id='passwordless_container']/div[{i + 1}]/input") otp_field.send_keys(digit) - # Wait for authenticated screen - self.altdriver.wait_for_current_scene_to_be("AuthenticatedScene") - break except: # If the field is not found, continue to the next context @@ -100,4 +88,32 @@ def test_1_pkce_login(self): # If target context was not found, raise an error if not target_context: - raise Exception("Could not find the email field in any webview context.") \ No newline at end of file + raise Exception("Could not find the email field in any webview context.") + + def test_1_pkce_login(self): + # Select use PKCE auth + self.altdriver.find_object(By.NAME, "PKCE").tap() + + # Wait for unauthenticated screen + self.altdriver.wait_for_current_scene_to_be("UnauthenticatedScene") + + # Login + loginBtn = self.altdriver.wait_for_object(By.NAME, "LoginBtn") + loginBtn.tap() + + self.login() + + # Wait for authenticated screen + self.altdriver.wait_for_current_scene_to_be("AuthenticatedScene") + + def test_2_other_functions(self): + self.test_0_other_functions() + + def test_3_passport_functions(self): + self.test_1_passport_functions() + + def test_4_imx_functions(self): + self.test_2_imx_functions() + + def test_5_zkevm_functions(self): + self.test_3_zkevm_functions() \ No newline at end of file