Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit baa4ff1

Browse files
fix: match ios device by type and name
1 parent e98b4a2 commit baa4ff1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

‎lib/appium-driver.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,16 @@ export class AppiumDriver {
344344
&& sessionInfoDetails.platformName.toLowerCase() === "ios"
345345
&& sessionInfoDetails.platformVersion.startsWith("13")) {
346346
try {
347-
const devicesInfos = IOSController.devicesDisplaysInfos();
348-
const matches = devicesInfos.filter(d => sessionInfoDetails.deviceName.includes(d.deviceType));
349-
if (matches && matches.length > 0) {
350-
const deviceType = matches[matches.length - 1];
347+
const devicesInfos = IOSController.devicesDisplaysInfos()
348+
.filter(d => sessionInfoDetails.deviceName.includes(d.deviceType));
349+
350+
if (devicesInfos.length > 0) {
351+
// sort devices by best match - in case we have iPhone XR 13 -> it will match device type 'iPhone X' and 'iPhone XR' -> after sort we will pick first longest match
352+
devicesInfos
353+
.sort((a, b) => {
354+
return sessionInfoDetails.deviceName.replace(a.deviceType, "").length - sessionInfoDetails.deviceName.replace(b.deviceType, "").length
355+
});
356+
const deviceType = devicesInfos[0];
351357
args.device.viewportRect.y += deviceType.actionBarHeight;
352358
args.device.viewportRect.height -= deviceType.actionBarHeight;
353359
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /