Skip to content

Commit 8c438b9

Browse files
authored
Merge pull request #379 from immutable/test/ios-imx-zkevm-fx
test: ui tests for ios passport, imx, zkevm and other functions
2 parents 713e23a + a8b742e commit 8c438b9

File tree

1 file changed

+36
-20
lines changed

1 file changed

+36
-20
lines changed

sample/Tests/test/test_ios.py

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
from selenium.webdriver.support.ui import WebDriverWait
1111
from selenium.webdriver.support import expected_conditions as EC
1212

13-
from alttester import AltDriver, By
13+
from alttester import *
1414

15-
from test import TestConfig
15+
from test import TestConfig, UnityTest
1616

1717
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / 'src'))
1818
from fetch_otp import fetch_code
1919

2020
# To run this test on an actual Android device: appium --base-path /wd/hub --allow-insecure chromedriver_autodownload
21-
class TestBase(unittest.TestCase):
21+
class TestBase(UnityTest):
2222
altdriver = None
2323
appium_driver = None
2424

@@ -37,21 +37,12 @@ def setUpClass(cls):
3737
@classmethod
3838
def tearDownClass(cls):
3939
print("\nEnding")
40-
cls.altdriver.stop()
4140
cls.appium_driver.quit()
41+
cls.altdriver.stop()
4242

43-
def test_1_pkce_login(self):
44-
# Select use PKCE auth
45-
self.altdriver.find_object(By.NAME, "PKCE").tap()
46-
47-
# Wait for unauthenticated screen
48-
self.altdriver.wait_for_current_scene_to_be("UnauthenticatedScene")
49-
50-
# Login
51-
loginBtn = self.altdriver.wait_for_object(By.NAME, "LoginBtn")
52-
loginBtn.tap()
53-
54-
driver = self.appium_driver
43+
@classmethod
44+
def login(cls):
45+
driver = cls.appium_driver
5546

5647
# Wait for the ASWebAuthenticationSession context to appear
5748
WebDriverWait(driver, 30).until(lambda d: len(d.contexts) > 2)
@@ -90,14 +81,39 @@ def test_1_pkce_login(self):
9081
otp_field = driver.find_element(by=AppiumBy.XPATH, value=f"//div[@id='passwordless_container']/div[{i + 1}]/input")
9182
otp_field.send_keys(digit)
9283

93-
# Wait for authenticated screen
94-
self.altdriver.wait_for_current_scene_to_be("AuthenticatedScene")
95-
9684
break
9785
except:
9886
# If the field is not found, continue to the next context
9987
print(f"Email field not found in context: {context}")
10088

10189
# If target context was not found, raise an error
10290
if not target_context:
103-
raise Exception("Could not find the email field in any webview context.")
91+
raise Exception("Could not find the email field in any webview context.")
92+
93+
def test_1_pkce_login(self):
94+
# Select use PKCE auth
95+
self.altdriver.find_object(By.NAME, "PKCE").tap()
96+
97+
# Wait for unauthenticated screen
98+
self.altdriver.wait_for_current_scene_to_be("UnauthenticatedScene")
99+
100+
# Login
101+
loginBtn = self.altdriver.wait_for_object(By.NAME, "LoginBtn")
102+
loginBtn.tap()
103+
104+
self.login()
105+
106+
# Wait for authenticated screen
107+
self.altdriver.wait_for_current_scene_to_be("AuthenticatedScene")
108+
109+
def test_2_other_functions(self):
110+
self.test_0_other_functions()
111+
112+
def test_3_passport_functions(self):
113+
self.test_1_passport_functions()
114+
115+
def test_4_imx_functions(self):
116+
self.test_2_imx_functions()
117+
118+
def test_5_zkevm_functions(self):
119+
self.test_3_zkevm_functions()

0 commit comments

Comments
 (0)