Skip to content

[DX-3536] test: ui tests for ios passport, imx, zkevm and other functions #379

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
Jan 22, 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
56 changes: 36 additions & 20 deletions sample/Tests/test/test_ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -90,14 +81,39 @@ 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
print(f"Email field not found in context: {context}")

# 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.")
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()
Loading