parent
1608e29d27
commit
bd8673f832
|
@ -1915,7 +1915,9 @@ public class IosAutomationHandler extends AbstractAutomationHandler {
|
|||
HttpUtils.downloadFileToLocal(picDownloadUrl, System.getProperty("user.dir") + "/tempPic", picName);
|
||||
File file = new File(System.getProperty("user.dir") + "/tempPic/" + picName);
|
||||
String targetBase64 = Base64.encode(file);
|
||||
File sourceFile = ScreenShotUtils.getIOSMobileScreenShot(serial);
|
||||
|
||||
File sourceFile = deviceHandleHelper.getScreenShotFile(serial);
|
||||
|
||||
String sourceBase64 = Base64.encode(sourceFile);
|
||||
if (StringUtils.isNotBlank(targetBase64) && StringUtils.isNotBlank(sourceBase64)) {
|
||||
Map<String, BigDecimal> resultPoint = null;
|
||||
|
@ -1935,7 +1937,7 @@ public class IosAutomationHandler extends AbstractAutomationHandler {
|
|||
resultPoint = (Map<String, BigDecimal>) bodyMap.get("data");
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
logger.error("找图像地址有误,:{}", e);
|
||||
logger.error("找图像地址有误", e);
|
||||
} catch (Exception e) {
|
||||
logger.error("请求图像解析服务失败,参数:{},错误:{}", JSON.toJSONString(param), e);
|
||||
}
|
||||
|
@ -1952,7 +1954,7 @@ public class IosAutomationHandler extends AbstractAutomationHandler {
|
|||
result.setX(clickTrueX);
|
||||
result.setY(clickTrueY);
|
||||
} catch (IOException e) {
|
||||
logger.error("转换base64图片失败:{}", e);
|
||||
logger.error("转换base64图片失败", e);
|
||||
}
|
||||
} else {
|
||||
logger.warn("步骤【{}】未找到对应的图像", request.getStepToken());
|
||||
|
|
|
@ -80,4 +80,6 @@ public abstract class IosDeviceHandleHelper {
|
|||
public abstract boolean activateApp(String deviceId, String appPackage);
|
||||
|
||||
public abstract File getScreenShotFile(String deviceId, Integer startX, Integer startY, Integer cutWidth, Integer cutHeight, Integer screenWidth, Integer screenHeight);
|
||||
|
||||
public abstract File getScreenShotFile(String deviceId);
|
||||
}
|
||||
|
|
|
@ -206,19 +206,23 @@ public class LinuxAndWindowsIosHandleHelper extends IosDeviceHandleHelper {
|
|||
*/
|
||||
@Override
|
||||
public File getScreenShotFile(String deviceId, Integer startX, Integer startY, Integer cutWidth, Integer cutHeight, Integer screenWidth, Integer screenHeight) {
|
||||
if (cutWidth <= 0 || cutHeight <= 0) {
|
||||
throw new ExecuteException("截取图片的宽高不满足要求");
|
||||
}
|
||||
File snapShotFile = null;
|
||||
File cutFile = null;
|
||||
try {
|
||||
snapShotFile = ScreenShotUtils.getIOSMobileScreenShot(deviceId);
|
||||
if (null == snapShotFile) {
|
||||
if (!snapShotFile.exists()) {
|
||||
logger.debug("设备【{}】未截取到图片",deviceId);
|
||||
throw new ExecuteException("未截取到图片");
|
||||
}
|
||||
cutFile = cutImageFile(snapShotFile, deviceId, startX, startY, cutWidth, cutHeight, screenWidth, screenHeight);
|
||||
logger.debug("设备【{}】截取到的图片为:{}",deviceId,cutFile.getAbsolutePath());
|
||||
if (null != startX && null != startY) {
|
||||
if (cutWidth <= 0 || cutHeight <= 0) {
|
||||
throw new ExecuteException("截取图片的宽高不满足要求");
|
||||
}
|
||||
cutFile = cutImageFile(snapShotFile, deviceId, startX, startY, cutWidth, cutHeight, screenWidth, screenHeight);
|
||||
logger.debug("设备【{}】截取到的图片为:{}", deviceId, cutFile.getAbsolutePath());
|
||||
} else {
|
||||
cutFile = snapShotFile;
|
||||
}
|
||||
return cutFile;
|
||||
} catch (ExecuteException e) {
|
||||
logger.error("截图失败", e);
|
||||
|
@ -235,4 +239,9 @@ public class LinuxAndWindowsIosHandleHelper extends IosDeviceHandleHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getScreenShotFile(String deviceId) {
|
||||
return getScreenShotFile(deviceId, null, null, null, null, null, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,9 +81,6 @@ public class MacIosHandleHelper extends IosDeviceHandleHelper {
|
|||
|
||||
@Override
|
||||
public File getScreenShotFile(String deviceId, Integer startX, Integer startY, Integer cutWidth, Integer cutHeight, Integer screenWidth, Integer screenHeight) {
|
||||
if (cutWidth <= 0 || cutHeight <= 0) {
|
||||
throw new ExecuteException("截取图片的宽高不满足要求");
|
||||
}
|
||||
PyMobileDevice.SpecificAppleDeviceInfo specificAppleDeviceInfo = IOSDeviceManager.getInstance().getSpecificAppleDeviceInfo(deviceId);
|
||||
File file = null;
|
||||
File screenShotFile = null;
|
||||
|
@ -96,6 +93,9 @@ public class MacIosHandleHelper extends IosDeviceHandleHelper {
|
|||
logger.debug("设备【{}】截图的结果:{}",deviceId,screenShotFile.getAbsolutePath());
|
||||
}
|
||||
if (null != startX || null != startY) {
|
||||
if (cutWidth <= 0 || cutHeight <= 0) {
|
||||
throw new ExecuteException("截取图片的宽高不满足要求");
|
||||
}
|
||||
file = cutImageFile(screenShotFile, deviceId, startX, startY, cutWidth, cutHeight, screenWidth, screenHeight);
|
||||
logger.debug("截取出来的图像为:{}", file.getAbsolutePath());
|
||||
} else {
|
||||
|
@ -111,4 +111,15 @@ public class MacIosHandleHelper extends IosDeviceHandleHelper {
|
|||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全屏截图
|
||||
*
|
||||
* @param deviceId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public File getScreenShotFile(String deviceId) {
|
||||
return getScreenShotFile(deviceId, null, null, null, null, null, null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue