Skip to content

fix: resolve device type by device name #277

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
Nov 11, 2019
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
14 changes: 10 additions & 4 deletions lib/appium-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,16 @@ export class AppiumDriver {
&& sessionInfoDetails.platformName.toLowerCase() === "ios"
&& sessionInfoDetails.platformVersion.startsWith("13")) {
try {
const devicesInfos = IOSController.devicesDisplaysInfos();
const matches = devicesInfos.filter(d => sessionInfoDetails.deviceName.includes(d.deviceType));
if (matches && matches.length > 0) {
const deviceType = matches[matches.length - 1];
const devicesInfos = IOSController.devicesDisplaysInfos()
.filter(d => sessionInfoDetails.deviceName.includes(d.deviceType));

if (devicesInfos.length > 0) {
// 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
devicesInfos
.sort((a, b) => {
return sessionInfoDetails.deviceName.replace(a.deviceType, "").length - sessionInfoDetails.deviceName.replace(b.deviceType, "").length
});
const deviceType = devicesInfos[0];
args.device.viewportRect.y += deviceType.actionBarHeight;
args.device.viewportRect.height -= deviceType.actionBarHeight;
}
Expand Down