Skip to content

Commit 1f62cd1

Browse files
committed
test: bump Appium to 3.2.0
1 parent b7ec7e5 commit 1f62cd1

File tree

4 files changed

+41
-10
lines changed

4 files changed

+41
-10
lines changed

appium/scripts/run-local.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,16 @@ build_rn_ios() {
233233
(cd "$DEMO_DIR/ios" && pod install)
234234

235235
info "Building debug .app for simulator (this may take a few minutes)..."
236-
(cd "$DEMO_DIR/ios" && xcodebuild \
236+
(cd "$DEMO_DIR/ios" && FORCE_BUNDLING=1 xcodebuild \
237237
-workspace demo.xcworkspace \
238238
-scheme demo \
239239
-configuration Debug \
240240
-sdk iphonesimulator \
241241
-derivedDataPath build \
242242
CODE_SIGN_IDENTITY="" \
243243
CODE_SIGNING_REQUIRED=NO \
244-
CODE_SIGNING_ALLOWED=NO)
244+
CODE_SIGNING_ALLOWED=NO \
245+
COMPILER_INDEX_STORE_ENABLE=NO)
245246

246247
[[ -d "$APP_PATH" ]] || error ".app not found after build at $APP_PATH"
247248
info "App built: $APP_PATH"
@@ -252,7 +253,7 @@ build_rn_android() {
252253
setup_rn_sdk
253254

254255
info "Building debug APK (this may take a few minutes)..."
255-
(cd "$DEMO_DIR/android" && ./gradlew assembleDebug)
256+
(cd "$DEMO_DIR" && bunx react-native build-android --mode=debug)
256257

257258
[[ -f "$APP_PATH" ]] || error ".apk not found after build at $APP_PATH"
258259
info "App built: $APP_PATH"

appium/tests/helpers/app.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ export async function waitForAlert(timeoutMs = 10_000): Promise<string | null> {
145145
*
146146
* iOS: uses XCUITest `mobile: alert` API.
147147
* Android: looks for the standard permission dialog "Allow" button via
148-
* UiAutomator (works for POST_NOTIFICATIONS, location, etc.).
148+
* UiAutomator (works for POST_NOTIFICATIONS, location, etc.). Handles
149+
* stock Android, Samsung (`com.samsung.android.permissioncontroller`),
150+
* and legacy `com.android.packageinstaller` package variants.
149151
*/
150152
export async function acceptSystemAlert(timeoutMs = 10_000): Promise<string | null> {
151153
const platform = getPlatform();
@@ -157,14 +159,42 @@ export async function acceptSystemAlert(timeoutMs = 10_000): Promise<string | nu
157159
return text;
158160
}
159161

160-
const allowBtn = await $('android=new UiSelector().text("Allow")');
161-
await allowBtn.waitForDisplayed({ timeout: timeoutMs });
162+
// Try resource-id first (most robust across OEMs), then fall back to
163+
// text match. "Don't allow" contains "Allow" as a substring, so we
164+
// must use exact `text()` rather than `textContains()`.
165+
const allowSelectors = [
166+
'new UiSelector().resourceIdMatches(".*:id/permission_allow_button")',
167+
'new UiSelector().resourceIdMatches(".*:id/permission_allow_foreground_only_button")',
168+
'new UiSelector().resourceIdMatches(".*:id/permission_allow_one_time_button")',
169+
'new UiSelector().text("Allow")',
170+
'new UiSelector().text("ALLOW")',
171+
'new UiSelector().text("While using the app")',
172+
];
173+
174+
let allowBtn: Awaited<ReturnType<typeof $>> | null = null;
175+
const deadline = Date.now() + timeoutMs;
176+
while (Date.now() < deadline) {
177+
for (const sel of allowSelectors) {
178+
const el = await $(`android=${sel}`);
179+
if (await el.isDisplayed().catch(() => false)) {
180+
allowBtn = el;
181+
break;
182+
}
183+
}
184+
if (allowBtn) break;
185+
await driver.pause(250);
186+
}
187+
188+
if (!allowBtn) return null;
189+
162190
let text = 'Permission dialog';
163191
try {
164192
const msgEl = await $(
165-
'android=new UiSelector().resourceId("com.android.permissioncontroller:id/permission_message")',
193+
'android=new UiSelector().resourceIdMatches(".*:id/permission_message")',
166194
);
167-
text = await msgEl.getText();
195+
if (await msgEl.isDisplayed().catch(() => false)) {
196+
text = await msgEl.getText();
197+
}
168198
} catch {
169199
/* best-effort */
170200
}

appium/wdio.android.conf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const config: WebdriverIO.Config = {
99
platformName: 'Android',
1010
'appium:app': isLocal ? process.env.APP_PATH : process.env.BROWSERSTACK_APP_URL,
1111
'appium:deviceName': process.env.DEVICE || 'Samsung Galaxy S24',
12-
'appium:platformVersion': process.env.OS_VERSION || '16',
12+
'appium:platformVersion': process.env.OS_VERSION || '16.0',
1313
'appium:automationName': 'UiAutomator2',
1414
...(process.env.BUNDLE_ID ? { 'appium:appPackage': process.env.BUNDLE_ID } : {}),
1515
'appium:autoGrantPermissions': false,

appium/wdio.shared.conf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const bstackOptions = {
2121
sessionName: process.env.SDK_TYPE || 'unknown',
2222
debug: true,
2323
networkLogs: true,
24-
appiumVersion: '2.6',
24+
appiumVersion: '3.2.0',
2525
};
2626

2727
export const sharedConfig: WebdriverIO.Config = {

0 commit comments

Comments
 (0)