Skip to content

Commit

Permalink
feat: set snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed May 25, 2023
1 parent a6d7f10 commit 7e9bc2d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2238,7 +2238,8 @@ public void getElementTextAndAssertWithOperation(HandleContext handleContext, St
case "notEqual" -> assertNotEquals(realValue, expect);
case "contain" -> assertTrue(realValue.contains(expect));
case "notContain" -> assertFalse(realValue.contains(expect));
default -> throw new SonicRespException("未支持的文本断言操作类型" + operation + ",无法进行文本断言");
default ->
throw new SonicRespException("未支持的文本断言操作类型" + operation + ",无法进行文本断言");
}
} catch (AssertionError e) {
handleContext.setE(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,18 @@ public void startIOSDriver(String udId, int wdaPort) throws Exception {
}
iosDriver.getWdaClient().setGlobalTimeOut(5 * 60 * 1000);
log.sendStepLog(StepType.PASS, "连接 WebDriverAgent 成功", "");
JSONObject appiumSettings = new JSONObject();
appiumSettings.put("snapshotMaxDepth", 30);
appiumSettings(appiumSettings);
}

public void setSnapshotMaxDepth(HandleContext handleContext, int depth) {
handleContext.setStepDes("设置控件获取最大遍历深度");
handleContext.setDetail("设置为 " + depth + " 层");
try {
JSONObject settings = new JSONObject();
settings.put("snapshotMaxDepth", depth);
appiumSettings(settings);
} catch (Exception e) {
handleContext.setE(e);
}
}

public void closeIOSDriver() {
Expand Down Expand Up @@ -1518,7 +1527,8 @@ public void getElementTextAndAssertWithOperation(HandleContext handleContext, St
case "notEqual" -> assertNotEquals(realValue, expect);
case "contain" -> assertTrue(realValue.contains(expect));
case "notContain" -> assertFalse(realValue.contains(expect));
default -> throw new SonicRespException("未支持的文本断言操作类型" + operation + ",无法进行文本断言");
default ->
throw new SonicRespException("未支持的文本断言操作类型" + operation + ",无法进行文本断言");
}
} catch (AssertionError e) {
handleContext.setE(e);
Expand Down Expand Up @@ -1643,6 +1653,7 @@ public void runStep(JSONObject stepJSON, HandleContext handleContext) throws Thr
case "freezeSource" -> freezeSource(handleContext);
case "thawSource" -> thawSource(handleContext);
case "closePocoDriver" -> closePocoDriver(handleContext);
case "setSnapshotMaxDepth" -> setSnapshotMaxDepth(handleContext, step.getInteger("content"));
case "iteratorPocoElement" ->
iteratorPocoElement(handleContext, eleList.getJSONObject(0).getString("eleName"), eleList.getJSONObject(0).getString("eleType")
, eleList.getJSONObject(0).getString("eleValue"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,14 @@ public void onMessage(String message, Session session) {
try {
JSONObject result = new JSONObject();
result.put("msg", "tree");
result.put("detail", iosStepHandler.getResource());
HandleContext handleContext = new HandleContext();
if (msg.getBoolean("needImg")) {
result.put("img", iosStepHandler.stepScreen(handleContext));
}
if (msg.getInteger("depth") != null) {
iosStepHandler.setSnapshotMaxDepth(handleContext, msg.getInteger("depth"));
}
result.put("detail", iosStepHandler.getResource());
if (handleContext.getE() != null) {
log.error(handleContext.getE().getMessage());
JSONObject resultFail = new JSONObject();
Expand Down

0 comments on commit 7e9bc2d

Please sign in to comment.