10
10
from selenium .webdriver .support .ui import WebDriverWait
11
11
from selenium .webdriver .support import expected_conditions as EC
12
12
13
- from alttester import AltDriver , By
13
+ from alttester import *
14
14
15
- from test import TestConfig
15
+ from test import TestConfig , UnityTest
16
16
17
17
sys .path .insert (0 , str (Path (__file__ ).resolve ().parent .parent / 'src' ))
18
18
from fetch_otp import fetch_code
19
19
20
20
# 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 ):
22
22
altdriver = None
23
23
appium_driver = None
24
24
@@ -37,21 +37,12 @@ def setUpClass(cls):
37
37
@classmethod
38
38
def tearDownClass (cls ):
39
39
print ("\n Ending" )
40
- cls .altdriver .stop ()
41
40
cls .appium_driver .quit ()
41
+ cls .altdriver .stop ()
42
42
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
55
46
56
47
# Wait for the ASWebAuthenticationSession context to appear
57
48
WebDriverWait (driver , 30 ).until (lambda d : len (d .contexts ) > 2 )
@@ -90,14 +81,39 @@ def test_1_pkce_login(self):
90
81
otp_field = driver .find_element (by = AppiumBy .XPATH , value = f"//div[@id='passwordless_container']/div[{ i + 1 } ]/input" )
91
82
otp_field .send_keys (digit )
92
83
93
- # Wait for authenticated screen
94
- self .altdriver .wait_for_current_scene_to_be ("AuthenticatedScene" )
95
-
96
84
break
97
85
except :
98
86
# If the field is not found, continue to the next context
99
87
print (f"Email field not found in context: { context } " )
100
88
101
89
# If target context was not found, raise an error
102
90
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