This commit is contained in:
2021-10-18 18:16:22 +08:00
parent d9188f8499
commit d556b49e68
7 changed files with 201 additions and 109 deletions

View File

@@ -469,15 +469,15 @@ public abstract class BaseAblStep implements AblStepHandler.StepListener {
nodeZuobiao(child3); nodeZuobiao(child3);
for (int r = 0; r < child3.getChildCount(); r++) { for (int r = 0; r < child3.getChildCount(); r++) {
AccessibilityNodeInfo child4 = child3.getChild(r); AccessibilityNodeInfo child4 = child3.getChild(r);
// Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText()+ ":" + child4.getContentDescription()); Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText()+ ":" + child4.getContentDescription());
// nodeZuobiao(child4); nodeZuobiao(child4);
// for (int m = 0; m < child4.getChildCount(); m++) { for (int m = 0; m < child4.getChildCount(); m++) {
// AccessibilityNodeInfo child5 = child4.getChild(m); AccessibilityNodeInfo child5 = child4.getChild(m);
// Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText()+ ":" + child5.getContentDescription()); Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText()+ ":" + child5.getContentDescription());
// nodeZuobiao(child5); nodeZuobiao(child5);
// for (int p = 0; p < child5.getChildCount();p++) { for (int p = 0; p < child5.getChildCount();p++) {
// AccessibilityNodeInfo child6 = child5.getChild(p); AccessibilityNodeInfo child6 = child5.getChild(p);
// Log.e("TIAOSHI###", "----7Node:" + child6.getClassName() + ":" + child6.getText()+ ":" + child6.getContentDescription()); Log.e("TIAOSHI###", "----7Node:" + child6.getClassName() + ":" + child6.getText()+ ":" + child6.getContentDescription());
// for (int t = 0; t < child6.getChildCount();t++) { // for (int t = 0; t < child6.getChildCount();t++) {
// AccessibilityNodeInfo child7 = child6.getChild(t); // AccessibilityNodeInfo child7 = child6.getChild(t);
// Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText()+ ":" + child7.getContentDescription()); // Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText()+ ":" + child7.getContentDescription());
@@ -487,8 +487,8 @@ public abstract class BaseAblStep implements AblStepHandler.StepListener {
// //
// } // }
// } // }
// } }
// } }
} }
} }
} }

View File

@@ -469,6 +469,28 @@ public class AblViewUtil {
} }
return flag; return flag;
} }
/**
* 根据范围获和输入的文本获取节点
*/
public static AccessibilityNodeInfo getNodeInfo(String str) {
AccessibilityNodeInfo nodeInfo = null;
List<AccessibilityNodeInfo> nodeInfos = AblViewUtil.findByText(str);
for (int i=0;i<nodeInfos.size();i++){
AccessibilityNodeInfo child = nodeInfos.get(i);
Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
nodeZuobiao(child);
Rect rect = new Rect();
child.getBoundsInScreen(rect);
if(rect.left>0&&rect.top>2000&&rect.top<=2210&&rect.bottom>0&&rect.bottom<=2210&&rect.right<1080) {
Log.e("TIAOSHI###", "----twoNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
nodeZuobiao(child);
nodeInfo = child;
}
}
return nodeInfo;
}
/** /**
* 查看节点的坐标点 * 查看节点的坐标点
*/ */

View File

@@ -404,7 +404,7 @@ class NoticeBase extends BaseAblStep {
// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); // Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription());
for (int r = 0; r < child3.getChildCount(); r++) { for (int r = 0; r < child3.getChildCount(); r++) {
AccessibilityNodeInfo child4 = child3.getChild(r); AccessibilityNodeInfo child4 = child3.getChild(r);
// Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription()); Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription());
switch (type) { switch (type) {
case "1"://说点什么 case "1"://说点什么
if ("android.widget.TextView".equals(child4.getClassName())) { if ("android.widget.TextView".equals(child4.getClassName())) {
@@ -554,7 +554,7 @@ class NoticeBase extends BaseAblStep {
for (int i = 0; i < root.getChildCount(); i++) { for (int i = 0; i < root.getChildCount(); i++) {
AccessibilityNodeInfo child = root.getChild(i); AccessibilityNodeInfo child = root.getChild(i);
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
if ("android.widget.Button".equals(child.getClassName())) { if ("android.widget.ImageView".equals(child.getClassName())) {
if(child.getContentDescription()!=null) { if(child.getContentDescription()!=null) {
if (child.getContentDescription().toString().equals("发送")) { if (child.getContentDescription().toString().equals("发送")) {
nodeinfo = child; nodeinfo = child;

View File

@@ -44,13 +44,130 @@ public class TestAblStep0 extends BaseAblStep {
break; break;
case AblSteps.STEP_2: case AblSteps.STEP_2:
AblViewUtil.mySleep(2); AblViewUtil.mySleep(5);
// getNodeInfoh(); getNodeInfoh();
cancelGuanzhu(AblService.getInstance()); // cancelGuanzhu(AblService.getInstance());
break; break;
default: default:
} }
} }
/**
* 发送节点
* @return
*/
public AccessibilityNodeInfo geouyintdd() {
AccessibilityNodeInfo nodeinfo = null;
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
for (int i = 0; i < root.getChildCount(); i++) {
AccessibilityNodeInfo child = root.getChild(i);
Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
if ("android.widget.ImageView".equals(child.getClassName())) {
if(child.getContentDescription()!=null) {
if (child.getContentDescription().toString().equals("发送")) {
nodeinfo = child;
}
}
}
}
return nodeinfo;
}
/**
* 输入框
* @return
*/
public AccessibilityNodeInfo getedittext() {
AccessibilityNodeInfo nodeinfo = null;
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
for (int i = 0; i < root.getChildCount(); i++) {
AccessibilityNodeInfo child = root.getChild(i);
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
if ("android.widget.EditText".equals(child.getClassName())) {
nodeinfo=child;
}
}
return nodeinfo;
}
/**
* 判断当前页面是否包含某文本
*/
public AccessibilityNodeInfo isContainText(String str) {
AccessibilityNodeInfo nodeInfo = null;
List<AccessibilityNodeInfo> nodeInfos = AblViewUtil.findByText(str);
for (int i=0;i<nodeInfos.size();i++){
AccessibilityNodeInfo child = nodeInfos.get(i);
Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
nodeZuobiao(child);
Rect rect = new Rect();
child.getBoundsInScreen(rect);
if(rect.left>0&&rect.top>2000&&rect.top<=2210&&rect.bottom>0&&rect.bottom<=2210&&rect.right<1080) {
Log.e("TIAOSHI###", "----twoNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
nodeZuobiao(child);
nodeInfo = child;
}
}
return nodeInfo;
}
/**
* 点击直播间下方的更多按钮(备注:通过搜索点击直播进去的可用)
* 1.说点什么
* 2.更多
* 3.礼物
*/
public void clickmoreli(String type) {
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
for (int i = 0; i < root.getChildCount(); i++) {
AccessibilityNodeInfo child = root.getChild(i);
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
for (int y = 0; y < child.getChildCount(); y++) {
AccessibilityNodeInfo child1 = child.getChild(y);
// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription());
for (int j = 0; j < child1.getChildCount(); j++) {
AccessibilityNodeInfo child2 = child1.getChild(j);
// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription());
for (int x = 0; x < child2.getChildCount(); x++) {
AccessibilityNodeInfo child3 = child2.getChild(x);
Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription());
for (int r = 0; r < child3.getChildCount(); r++) {
AccessibilityNodeInfo child4 = child3.getChild(r);
Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription());
switch (type) {
case "1"://说点什么
if ("android.widget.TextView".equals(child4.getClassName())) {
if (child4.getText() != null) {
if (child4.getText().toString().equals("说点什么...")) {
AblService.getInstance().clickcommontwo(child4, "");
}
}
}
break;
case "2"://更多
if ("android.widget.Button".equals(child4.getClassName())) {
if (child4.getContentDescription().equals("更多")) {
AblService.getInstance().clickcommontwo(child4, "点击了更多");
}
}
break;
case "3"://礼物
if ("android.widget.Button".equals(child4.getClassName())) {
if (child4.getContentDescription().equals("礼物")) {
AblService.getInstance().clickcommontwo(child4, "");
}
}
break;
default:
}
}
}
}
}
}
}
private void cancelGuanzhu(AblService instance) { private void cancelGuanzhu(AblService instance) {
@@ -75,21 +192,14 @@ public class TestAblStep0 extends BaseAblStep {
for (int r = 0; r < child3.getChildCount(); r++) { for (int r = 0; r < child3.getChildCount(); r++) {
AccessibilityNodeInfo child4 = child3.getChild(r); AccessibilityNodeInfo child4 = child3.getChild(r);
Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription()); Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription());
// nodeZuobiao(child4);
// Rect rect = new Rect();
// if(child4!=null) {
// child4.getBoundsInScreen(rect);
// if (rect.top <= 2100) {
for (int m = 0; m < child4.getChildCount(); m++) { for (int m = 0; m < child4.getChildCount(); m++) {
AccessibilityNodeInfo child5 = child4.getChild(m); AccessibilityNodeInfo child5 = child4.getChild(m);
// Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText()+ ":" + child5.getContentDescription()); Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText()+ ":" + child5.getContentDescription());
nodeZuobiao(child5); // nodeZuobiao(child5);
yiguanzhu(child5); // yiguanzhu(child5);
} }
} }
} }
// }
// }
} }
} }
} }

View File

@@ -473,25 +473,41 @@ public class TestAblStep30 extends NoticeBase {
private void fasongpinglun(String conment) { private void fasongpinglun(String conment) {
//直播间话术 //直播间话术
AblViewUtil.mySleep(2); AblViewUtil.mySleep(3);
clickmoreli("1"); Log.e("TIAOSHI###", "开始点说点什么" );
AccessibilityNodeInfo containText = isContainText("说点什么...");
clickcommontwo(containText,"");
AblViewUtil.mySleep(2); AblViewUtil.mySleep(2);
//复制文本粘贴在留言板 //复制文本粘贴在留言板
AccessibilityNodeInfo getedittext = getedittext(); AccessibilityNodeInfo getedittext = getedittext();
Log.e("TIAOSHI###", "获得的关键词内容" + conment); Log.e("TIAOSHI###", "获得的关键词内容" + conment);
AblViewUtil.mySleep(1); AblViewUtil.mySleep(1);
if (SHEBEITIPE_VILUEONE.equals(ChangLiang.phonetype)) {
AblViewUtil.sayInput(conment, getedittext); AblViewUtil.sayInput(conment, getedittext);
} else {
//华为畅享20
AblViewUtil.sayInput(conment, getedittext);
}
AblViewUtil.mySleep(1); AblViewUtil.mySleep(1);
AccessibilityNodeInfo geouyintdd = geouyintdd(); AccessibilityNodeInfo geouyintdd = geouyintdd();
AblService.getInstance().clickcommontwo(geouyintdd, "点击发送"); AblService.getInstance().clickcommontwo(geouyintdd, "点击发送");
AblViewUtil.mySleep(2); AblViewUtil.mySleep(2);
} }
/**
* 判断当前页面是否包含某文本
*/
public AccessibilityNodeInfo isContainText(String str) {
AccessibilityNodeInfo nodeInfo = null;
List<AccessibilityNodeInfo> nodeInfos = AblViewUtil.findByText(str);
for (int i=0;i<nodeInfos.size();i++){
AccessibilityNodeInfo child = nodeInfos.get(i);
Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
nodeZuobiao(child);
Rect rect = new Rect();
child.getBoundsInScreen(rect);
if(rect.left>0&&rect.top>2000&&rect.top<=2210&&rect.bottom>0&&rect.bottom<=2210&&rect.right<1080) {
Log.e("TIAOSHI###", "----twoNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
nodeZuobiao(child);
nodeInfo = child;
}
}
return nodeInfo;
}
/** /**
* 直播间点赞 * 直播间点赞

View File

@@ -216,20 +216,13 @@ public class TestAblStep6 extends BaseAblStep {
for (int r = 0; r < child3.getChildCount(); r++) { for (int r = 0; r < child3.getChildCount(); r++) {
AccessibilityNodeInfo child4 = child3.getChild(r); AccessibilityNodeInfo child4 = child3.getChild(r);
Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription()); Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription());
// nodeZuobiao(child4);
// Rect rect = new Rect();
// if(child4!=null) {
// child4.getBoundsInScreen(rect);
// if (rect.top <= 2100) {
for (int m = 0; m < child4.getChildCount(); m++) { for (int m = 0; m < child4.getChildCount(); m++) {
AccessibilityNodeInfo child5 = child4.getChild(m); AccessibilityNodeInfo child5 = child4.getChild(m);
// Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText()+ ":" + child5.getContentDescription()); Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText()+ ":" + child5.getContentDescription());
nodeZuobiao(child5); nodeZuobiao(child5);
yiguanzhu(child5); yiguanzhu(child5);
} }
} }
// }
// }
} }
} }
} }

View File

@@ -1,49 +0,0 @@
package com.fisherbone.fuzhu.step;
import android.graphics.Rect;
import android.util.Log;
import android.view.accessibility.AccessibilityNodeInfo;
import com.fisherbone.fuzhu.abllib.utils.AblViewUtil;
import java.util.List;
/**
*
*/
public class methodUtil {
/**
* 判断当前页面是否包含某文本
*/
public static boolean isContainText(String str) {
boolean flag = false;
List<AccessibilityNodeInfo> nodeInfos = AblViewUtil.findByText(str);
for (int i=0;i<nodeInfos.size();i++){
AccessibilityNodeInfo child = nodeInfos.get(i);
Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
nodeZuobiao(child);
Rect rect = new Rect();
child.getBoundsInScreen(rect);
if(rect.left>0&&rect.top>0&&rect.top<=2210&&rect.bottom>0&&rect.bottom<=2210&&rect.right<1080) {
Log.e("TIAOSHI###", "----twoNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
nodeZuobiao(child);
flag = true;
}
}
return flag;
}
/**
* 查看节点的坐标点
*/
public static void nodeZuobiao(AccessibilityNodeInfo nodeinfo){
Rect rect = new Rect();
nodeinfo.getBoundsInScreen(rect);
Log.e("TIAOSHI###", "----显示节点的坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")");
}
}