Skip to content

Commit 5442e60

Browse files
authored
ci: use gha instead of Azure for iOS in Azure (#987)
ci: use gha instead of Azure for iOS in Azure
1 parent 67a561d commit 5442e60

8 files changed

+62
-40
lines changed

.github/workflows/functional-test.yml

+16-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
test_targets:
21-
- target: search_context/find_by_*.py remote_fs_tests.py safari_tests.py execute_driver_tests.py
21+
- target: test/functional/ios/search_context/find_by_*.py test/functional/ios/remote_fs_tests.py test/functional/ios/safari_tests.py test/functional/ios/execute_driver_tests.py
2222
name: func_test_ios1
23+
- target: test/functional/ios/applications_tests.py test/functional/ios/hw_actions_tests.py test/functional/ios/keyboard_tests.py
24+
name: func_test_ios2
25+
- target: test/functional/ios/screen_record_tests.py test/functional/ios/webdriver_tests.py
26+
name: func_test_ios3
2327

2428
runs-on: macos-14
2529

@@ -43,21 +47,29 @@ jobs:
4347
model: 'iPhone 15 Plus'
4448
os_version: '17.4'
4549

50+
# needed?
51+
- run: brew install ffmpeg
52+
4653
# Start Appium
4754
- run: npm install -g appium
4855
- run: |
4956
appium driver install xcuitest
5057
appium plugin install images
5158
appium plugin install execute-driver
52-
nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors --base-path=/wd/hub > appium.log &
59+
nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors > appium.log &
5360
5461
- name: Set up Python 3.9
5562
uses: actions/setup-python@v3
5663
with:
5764
python-version: 3.9
5865

59-
- run: python -m pytest ${{ test_targets.target}} --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
60-
working-directory: test/functional/ios
66+
- run: |
67+
# Separate 'run' creates differnet pipenv env. Does them in one run for now.
68+
pip install --upgrade pip
69+
pip install --upgrade pipenv
70+
pipenv lock --clear
71+
pipenv install -d --system
72+
pytest ${{ matrix.test_targets.target}} --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
6173
6274
- name: Save server output
6375
if: ${{ always() }}

ci-jobs/functional_test.yml

-16
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,6 @@ parameters:
66
CI: true
77

88
jobs:
9-
- template: ./functional/run_ios_test.yml
10-
parameters:
11-
name: 'func_test_ios1'
12-
vmImage: ${{ parameters.vmImage }}
13-
pytestOpt: ${{ parameters.pytestOpt }}
14-
testFiles: 'search_context/find_by_*.py remote_fs_tests.py safari_tests.py execute_driver_tests.py'
15-
CI: ${{ parameters.ci }}
16-
xcodeForIOS: ${{ parameters.xcodeForIOS }}
17-
- template: ./functional/run_ios_test.yml
18-
parameters:
19-
name: 'func_test_ios2'
20-
vmImage: ${{ parameters.vmImage }}
21-
pytestOpt: ${{ parameters.pytestOpt }}
22-
testFiles: 'applications_tests.py hw_actions_tests.py keyboard_tests.py screen_record_tests.py webdriver_tests.py'
23-
CI: ${{ parameters.ci }}
24-
xcodeForIOS: ${{ parameters.xcodeForIOS }}
259
- template: ./functional/run_android_test.yml
2610
parameters:
2711
name: 'func_test_android1'

test/apps/UICatalog.app.zip

-16.8 MB
Binary file not shown.

test/functional/ios/helper/desired_capabilities.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_desired_capabilities(app: Optional[str] = None) -> Dict[str, Any]:
2828
desired_caps: Dict[str, Any] = {
2929
'deviceName': iphone_device_name(),
3030
'platformName': 'iOS',
31-
'platformVersion': '15.5',
31+
'platformVersion': '17.4',
3232
'automationName': 'XCUITest',
3333
'allowTouchIdEnroll': True,
3434
'wdaLocalPort': wda_port(),
@@ -70,7 +70,7 @@ def wda_port() -> int:
7070

7171

7272
def iphone_device_name() -> str:
73-
prefix = 'iPhone 12'
73+
prefix = 'iPhone 15 Plus'
7474
if PytestXdistWorker.NUMBER == PytestXdistWorker.gw(0):
7575
return f'{prefix} - 8100'
7676
elif PytestXdistWorker.NUMBER == PytestXdistWorker.gw(1):

test/functional/ios/helper/test_helper.py

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525

2626
class BaseTestCase(object):
27+
IOS_UICATALOG_APP_NAME = 'UIKitCatalog'
28+
2729
def setup_method(self) -> None:
2830
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
2931
self.driver = webdriver.Remote(SERVER_URL_BASE, options=XCUITestOptions().load_capabilities(desired_caps))

test/functional/ios/safari_tests.py

+29-3
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,44 @@
2424
class TestSafari:
2525
def setup_method(self) -> None:
2626
caps = get_desired_capabilities()
27-
caps.update({'browserName': 'safari', 'nativeWebTap': True, 'safariIgnoreFraudWarning': True})
27+
caps.update(
28+
{
29+
'bundleId': 'com.apple.mobilesafari',
30+
'nativeWebTap': True,
31+
'safariIgnoreFraudWarning': True,
32+
'webviewConnectTimeout': 100000,
33+
}
34+
)
2835
self.driver = webdriver.Remote(SERVER_URL_BASE, options=AppiumOptions().load_capabilities(caps))
2936

37+
# Fresh iOS 17.4 simulator may not show up the webview context with "safari"
38+
# after a fresh simlator instance creation.
39+
# Re-launch the process could be a workaround in my debugging.
40+
self.driver.terminate_app('com.apple.mobilesafari')
41+
self.driver.activate_app('com.apple.mobilesafari')
42+
3043
def teardown_method(self) -> None:
3144
self.driver.quit()
3245

3346
def test_context(self) -> None:
34-
assert 'NATIVE_APP' == self.driver.contexts[0]
35-
assert self.driver.contexts[1].startswith('WEBVIEW_')
47+
contexts = self.driver.contexts
48+
assert 'NATIVE_APP' == contexts[0]
49+
assert contexts[1].startswith('WEBVIEW_')
50+
self.driver.switch_to.context(contexts[1])
3651
assert 'WEBVIEW_' in self.driver.current_context
3752

3853
def test_get(self) -> None:
54+
ok = False
55+
contexts = self.driver.contexts
56+
for context in contexts:
57+
if context.startswith('WEBVIEW_'):
58+
self.driver.switch_to.context(context)
59+
ok = True
60+
break
61+
62+
if ok is False:
63+
assert False, 'Could not set WEBVIEW context'
64+
3965
self.driver.get('http://google.com')
4066
for _ in range(5):
4167
time.sleep(0.5)

test/functional/ios/search_context/find_by_element_webelement_tests.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
class TestFindByElementWebelement(BaseTestCase):
2020
def test_find_element_by_path(self) -> None:
21-
el = self.driver.find_element(by=AppiumBy.IOS_PREDICATE, value='wdName == "UICatalog"')
22-
assert 'UICatalog' == el.get_attribute('name')
21+
el = self.driver.find_element(by=AppiumBy.IOS_PREDICATE, value='wdName == "UIKitCatalog"')
22+
assert self.IOS_UICATALOG_APP_NAME == el.get_attribute('name')
2323

24-
c_el = el.find_elements(by=AppiumBy.IOS_PREDICATE, value='label == "Action Sheets"') # type: list
25-
assert 'Action Sheets' == c_el[0].get_attribute('name')
24+
c_el = el.find_elements(by=AppiumBy.IOS_PREDICATE, value='label == "UIKitCatalog"') # type: list
25+
assert self.IOS_UICATALOG_APP_NAME == c_el[0].get_attribute('name')
2626

2727
c_el = el.find_elements(by=AppiumBy.IOS_CLASS_CHAIN, value='**/XCUIElementTypeStaticText')
28-
assert 'UICatalog' == c_el[0].get_attribute('name')
28+
assert self.IOS_UICATALOG_APP_NAME == c_el[0].get_attribute('name')
2929

30-
c_el = el.find_elements(by=AppiumBy.ACCESSIBILITY_ID, value='UICatalog')
31-
assert 'UICatalog' == c_el[0].get_attribute('name')
30+
c_el = el.find_elements(by=AppiumBy.ACCESSIBILITY_ID, value='UIKitCatalog')
31+
assert self.IOS_UICATALOG_APP_NAME == c_el[0].get_attribute('name')

test/functional/ios/search_context/find_by_ios_class_chain_tests.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818

1919
class TestFindByIOClassChain(BaseTestCase):
2020
def test_find_element_by_path(self) -> None:
21+
el = self.driver.find_element(by=AppiumBy.IOS_CLASS_CHAIN, value='**/XCUIElementTypeNavigationBar')
22+
assert self.IOS_UICATALOG_APP_NAME == el.get_attribute('name')
23+
24+
def test_find_multiple_elements_by_path(self) -> None:
2125
els = self.driver.find_elements(
2226
by=AppiumBy.IOS_CLASS_CHAIN, value='XCUIElementTypeWindow/**/XCUIElementTypeStaticText'
2327
)
24-
assert 35 == len(els)
25-
assert 'UICatalog' == els[0].get_attribute('name')
26-
27-
def test_find_multiple_elements_by_path(self) -> None:
28-
el = self.driver.find_elements(by=AppiumBy.IOS_CLASS_CHAIN, value='XCUIElementTypeWindow/*/*/*')
29-
assert 2 == len(el)
30-
assert 'UICatalog' == el[0].get_attribute('name')
31-
assert el[1].get_attribute('name') is None
28+
assert 37 == len(els)
29+
assert self.IOS_UICATALOG_APP_NAME == els[0].get_attribute('name')

0 commit comments

Comments
 (0)