diff --git a/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java b/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java index 3535adb5..3a9dbe4e 100755 --- a/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java +++ b/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java @@ -803,6 +803,17 @@ public static String getSize(String udId) { } return size; } + public static int getScreenScale(String udId) { + String commandLine = "%s info -d com.apple.mobile.iTunes -u %s"; + String re = ProcessCommandTool.getProcessLocalCommandStr(String.format(commandLine, sib, udId)); + int size = 2; + try { + JSONObject r = JSON.parseObject(re); + size = r.getInteger("ScreenScaleFactor"); + } catch (Throwable ignored) { + } + return size; + } public static void mount(String udId) { String commandLine = "%s mount -u %s"; diff --git a/src/main/java/org/cloud/sonic/agent/tests/handlers/IOSStepHandler.java b/src/main/java/org/cloud/sonic/agent/tests/handlers/IOSStepHandler.java index 56f77025..8ccf6ed7 100755 --- a/src/main/java/org/cloud/sonic/agent/tests/handlers/IOSStepHandler.java +++ b/src/main/java/org/cloud/sonic/agent/tests/handlers/IOSStepHandler.java @@ -844,17 +844,9 @@ public void clickByImg(HandleContext handleContext, String des, String pathValue } if (findResult != null) { try { - String[] size = SibTool.getSize(udId).split("x"); - WindowSize windowSize = iosDriver.getWindowSize(); - int width; - int ori = SibTool.getOrientation(udId); - if (ori == 1 || ori == 2) { - width = windowSize.getWidth(); - } else { - width = windowSize.getHeight(); - } - iosDriver.tap(findResult.getX() / (Integer.parseInt(size[0]) / width), - findResult.getY() / (Integer.parseInt(size[0]) / width)); + double scale = SibTool.getScreenScale(udId); + iosDriver.tap((int) (findResult.getX()*1.0 / scale), + (int) (findResult.getY()*1.0 / scale)); } catch (Exception e) { log.sendStepLog(StepType.ERROR, "点击" + des + "失败!", ""); handleContext.setE(e);