From e7ebd9d2bb62b804b02d5238395c011e41a15484 Mon Sep 17 00:00:00 2001 From: caofengbin <1050430934@qq.com> Date: Sat, 20 May 2023 17:20:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=AD=E8=A8=80=E5=85=83=E7=B4=A0=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E4=B8=AA=E6=95=B0=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?POCO=E5=AE=9A=E4=BD=8D=E6=96=B9=E5=BC=8F=EF=BC=8Cagent=E7=AB=AF?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agent/tests/handlers/AndroidStepHandler.java | 12 ++++++++++++ .../sonic/agent/tests/handlers/IOSStepHandler.java | 13 ++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/cloud/sonic/agent/tests/handlers/AndroidStepHandler.java b/src/main/java/org/cloud/sonic/agent/tests/handlers/AndroidStepHandler.java index 64702aaa..8a681ef5 100755 --- a/src/main/java/org/cloud/sonic/agent/tests/handlers/AndroidStepHandler.java +++ b/src/main/java/org/cloud/sonic/agent/tests/handlers/AndroidStepHandler.java @@ -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; @@ -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; @@ -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")); 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 53982256..022ca1cb 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 @@ -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; @@ -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; @@ -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"));