Skip to content

Commit

Permalink
断言元素存在的个数,支持POCO定位方式,agent端逻辑修改,
Browse files Browse the repository at this point in the history
  • Loading branch information
caofengbin committed May 20, 2023
1 parent 465df6d commit e7ebd9d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class AndroidStepHandler {
// 断言元素个数,三种元素类型的定义
private static final int ANDROID_ELEMENT_TYPE = 1001;
private static final int WEB_ELEMENT_TYPE = 1002;
private static final int POCO_ELEMENT_TYPE = 1003;

public String getTargetPackage() {
return targetPackage;
Expand Down Expand Up @@ -864,6 +865,13 @@ public void isExistEleNum(HandleContext handleContext, String des, String select
} catch (Exception ignored) {
}
break;
case POCO_ELEMENT_TYPE:
try {
elementList = findPocoEleList(selector, pathValue);
} catch (Throwable e) {
// 查找元素不存在时会抛异常
}
break;
default:
handleContext.setE(new AssertionError("未知的元素类型" + elementType + ",无法断言元素个数"));
break;
Expand Down Expand Up @@ -2323,6 +2331,10 @@ public void runStep(JSONObject stepJSON, HandleContext handleContext) throws Thr
case "isExistPocoEle" ->
isExistPocoEle(handleContext, eleList.getJSONObject(0).getString("eleName"), eleList.getJSONObject(0).getString("eleType")
, eleList.getJSONObject(0).getString("eleValue"), step.getBoolean("content"));
case "isExistPocoEleNum" -> isExistEleNum(handleContext,
eleList.getJSONObject(0).getString("eleName"), eleList.getJSONObject(0).getString("eleType")
, eleList.getJSONObject(0).getString("eleValue"), step.getString("content"),
step.getInteger("text"), POCO_ELEMENT_TYPE);
case "pocoClick" ->
pocoClick(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 @@ -87,7 +87,7 @@ public class IOSStepHandler {
private String targetPackage = "";

private static final int IOS_ELEMENT_TYPE = 1004;
private static final int WEB_ELEMENT_TYPE = 1002;
private static final int POCO_ELEMENT_TYPE = 1005;

public String getTargetPackage() {
return targetPackage;
Expand Down Expand Up @@ -685,6 +685,13 @@ public void isExistEleNum(HandleContext handleContext, String des, String select
} catch (Exception ignored) {
}
break;
case POCO_ELEMENT_TYPE:
try {
elementList = findPocoEleList(selector, pathValue);
} catch (Throwable e) {
// 查找元素不存在时会抛异常
}
break;
default:
handleContext.setE(new AssertionError("未知的元素类型" + elementType + ",无法断言元素个数"));
break;
Expand Down Expand Up @@ -1564,6 +1571,10 @@ public void runStep(JSONObject stepJSON, HandleContext handleContext) throws Thr
case "isExistPocoEle" ->
isExistPocoEle(handleContext, eleList.getJSONObject(0).getString("eleName"), eleList.getJSONObject(0).getString("eleType")
, eleList.getJSONObject(0).getString("eleValue"), step.getBoolean("content"));
case "isExistPocoEleNum" -> isExistEleNum(handleContext,
eleList.getJSONObject(0).getString("eleName"), eleList.getJSONObject(0).getString("eleType")
, eleList.getJSONObject(0).getString("eleValue"), step.getString("content"),
step.getInteger("text"), POCO_ELEMENT_TYPE);
case "pocoClick" ->
pocoClick(handleContext, eleList.getJSONObject(0).getString("eleName"), eleList.getJSONObject(0).getString("eleType")
, eleList.getJSONObject(0).getString("eleValue"));
Expand Down

0 comments on commit e7ebd9d

Please sign in to comment.