From 576c010b3471140e2153d9d288c48e2620272e84 Mon Sep 17 00:00:00 2001
From: July <22679824@qq.com>
Date: Thu, 23 Jun 2022 00:19:24 +0800
Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=80=9A?=
=?UTF-8?q?=E8=BF=87UIAutomator=E6=96=B9=E6=B3=95(=E4=BB=85=E9=99=90Androi?=
=?UTF-8?q?d=E7=AB=AF/UIAutomator2=E5=BC=95=E6=93=8E)=E5=AE=9A=E4=BD=8D?=
=?UTF-8?q?=E6=8E=A7=E4=BB=B6=E5=85=83=E7=B4=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../org/cloud/sonic/agent/automation/AndroidStepHandler.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/main/java/org/cloud/sonic/agent/automation/AndroidStepHandler.java b/src/main/java/org/cloud/sonic/agent/automation/AndroidStepHandler.java
index eacb2275..672a6d8c 100755
--- a/src/main/java/org/cloud/sonic/agent/automation/AndroidStepHandler.java
+++ b/src/main/java/org/cloud/sonic/agent/automation/AndroidStepHandler.java
@@ -1491,6 +1491,9 @@ public WebElement findEle(String selector, String pathValue) {
case "cssSelectorAndText":
we = getWebElementByCssAndText(pathValue);
break;
+ case "androidUIAutomator":
+ //仅限自动化引擎为UIAutomator2时生效
+ we = androidDriver.findElementByAndroidUIAutomator(pathValue);
default:
log.sendStepLog(StepType.ERROR, "查找控件元素失败", "这个控件元素类型: " + selector + " 不存在!!!");
break;
From dc519c81a90cb4a1feefedd8bb443ef61d04ec6f Mon Sep 17 00:00:00 2001
From: ZhouYixun <291028775@qq.com>
Date: Thu, 23 Jun 2022 20:17:58 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Denv=E8=87=AA=E5=8A=A8?=
=?UTF-8?q?=E4=BC=A0=E5=8F=82=E7=9A=84bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config/application-sonic-agent.yml | 4 ++--
pom.xml | 2 +-
src/main/docker/config/application-sonic-agent.yml | 8 ++++----
src/main/docker/docker-compose.yml | 6 +++---
src/main/docker/docker-compose2.yml | 6 +++---
5 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/config/application-sonic-agent.yml b/config/application-sonic-agent.yml
index 2a65daea..590ec3e5 100644
--- a/config/application-sonic-agent.yml
+++ b/config/application-sonic-agent.yml
@@ -7,9 +7,9 @@ sonic:
# 替换为前端新增Agent生成的key
key: 29002272-4659-4808-a804-08ce3388b136
server:
- # 改成server的SERVER_HOST
+ # 改成server的SONIC_SERVER_HOST
host: 192.168.1.6
- # 改成server的SERVER_PORT
+ # 改成server的SONIC_SERVER_PORT
port: 3000
modules:
diff --git a/pom.xml b/pom.xml
index 369ba1c1..233fbcc7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.cloud.sonic
sonic-agent
- 1.4.1-beta
+ 1.4.1-rc
jar
diff --git a/src/main/docker/config/application-sonic-agent.yml b/src/main/docker/config/application-sonic-agent.yml
index ef3da492..04152b28 100644
--- a/src/main/docker/config/application-sonic-agent.yml
+++ b/src/main/docker/config/application-sonic-agent.yml
@@ -7,10 +7,10 @@ sonic:
# 替换为前端新增Agent生成的key
key: ${AGENT_KEY:235a35fd-5d0d-4533-905d-30d32902a12b}
server:
- # 改成server的SERVER_HOST
- host: ${SERVER_HOST:192.168.1.1}
- # 改成server的SERVER_PORT
- port: ${SERVER_PORT:3000}
+ # 改成server的SONIC_SERVER_HOST
+ host: ${SONIC_SERVER_HOST:192.168.1.1}
+ # 改成server的SONIC_SERVER_PORT
+ port: ${SONIC_SERVER_PORT:3000}
modules:
android:
diff --git a/src/main/docker/docker-compose.yml b/src/main/docker/docker-compose.yml
index 87c21c54..5255a906 100644
--- a/src/main/docker/docker-compose.yml
+++ b/src/main/docker/docker-compose.yml
@@ -1,11 +1,11 @@
version: '3'
services:
sonic-agent:
- image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-beta"
+ image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-rc"
environment:
# 对应server的env配置,注意防火墙关闭对应端口
- - SERVER_HOST=192.168.1.1
- - SERVER_PORT=3000
+ - SONIC_SERVER_HOST=192.168.1.1
+ - SONIC_SERVER_PORT=3000
# 替换为部署Agent机器的ipv4
- AGENT_HOST=192.168.1.1
# 替换为Agent服务的端口,可以自行更改
diff --git a/src/main/docker/docker-compose2.yml b/src/main/docker/docker-compose2.yml
index 5fb1de10..c1eefb7b 100644
--- a/src/main/docker/docker-compose2.yml
+++ b/src/main/docker/docker-compose2.yml
@@ -1,11 +1,11 @@
version: '3'
services:
sonic-agent:
- image: "sonicorg/sonic-agent-linux:v1.4.1-beta"
+ image: "sonicorg/sonic-agent-linux:v1.4.1-rc"
environment:
# 对应server的env配置,注意防火墙关闭对应端口
- - SERVER_HOST=192.168.1.1
- - SERVER_PORT=3000
+ - SONIC_SERVER_HOST=192.168.1.1
+ - SONIC_SERVER_PORT=3000
# 替换为部署Agent机器的ipv4
- AGENT_HOST=192.168.1.1
# 替换为Agent服务的端口,可以自行更改
From 6da39f2cada8eedc29b601f8dc1e47cdfc5ea6a3 Mon Sep 17 00:00:00 2001
From: ZhouYixun <291028775@qq.com>
Date: Tue, 28 Jun 2022 21:02:30 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BF=83=E8=B7=B3?=
=?UTF-8?q?=E6=9C=BA=E5=88=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config/application-sonic-agent.yml | 6 +++---
.../cloud/sonic/agent/transport/TransportClient.java | 5 ++++-
.../agent/transport/TransportConnectionThread.java | 11 ++++++++---
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/config/application-sonic-agent.yml b/config/application-sonic-agent.yml
index 590ec3e5..f0f360dd 100644
--- a/config/application-sonic-agent.yml
+++ b/config/application-sonic-agent.yml
@@ -1,14 +1,14 @@
sonic:
agent:
# 替换为部署Agent机器的ipv4
- host: 192.168.1.6
+ host: 192.168.1.4
# 替换为Agent服务的端口,可以自行更改
port: 7777
# 替换为前端新增Agent生成的key
key: 29002272-4659-4808-a804-08ce3388b136
server:
# 改成server的SONIC_SERVER_HOST
- host: 192.168.1.6
+ host: 192.168.1.4
# 改成server的SONIC_SERVER_PORT
port: 3000
@@ -20,7 +20,7 @@ modules:
use-adbkit: true
ios:
# 如果不需要连接iOS设备,请将true改为false。开启的windows用户请确保本机已安装iTunes
- enable: true
+ enable: false
# 替换为你自己使用的wda的bundleId,如果没有.xctrunner后缀会自动补全,建议使用公司的开发者证书
wda-bundle-id: com.sonic.WebDriverAgentRunner.xctrunner
appium:
diff --git a/src/main/java/org/cloud/sonic/agent/transport/TransportClient.java b/src/main/java/org/cloud/sonic/agent/transport/TransportClient.java
index f9be1fc4..2e665386 100644
--- a/src/main/java/org/cloud/sonic/agent/transport/TransportClient.java
+++ b/src/main/java/org/cloud/sonic/agent/transport/TransportClient.java
@@ -73,6 +73,9 @@ public void onMessage(String s) {
log.info("Agent <- Server message: {}", jsonObject);
TransportWorker.cachedThreadPool.execute(() -> {
switch (jsonObject.getString("msg")) {
+ case "pong":{
+ break;
+ }
case "auth": {
if (jsonObject.getString("result").equals("pass")) {
log.info("server auth successful!");
@@ -174,7 +177,7 @@ public void onMessage(String s) {
@Override
public void onClose(int i, String s, boolean b) {
if (TransportWorker.isKeyAuth) {
- log.info("Server disconnected. Retry in 10s...");
+ log.info("Server disconnected. Retry in 30s...");
}
TransportWorker.client = null;
}
diff --git a/src/main/java/org/cloud/sonic/agent/transport/TransportConnectionThread.java b/src/main/java/org/cloud/sonic/agent/transport/TransportConnectionThread.java
index 1ec80ea0..ee9587b0 100644
--- a/src/main/java/org/cloud/sonic/agent/transport/TransportConnectionThread.java
+++ b/src/main/java/org/cloud/sonic/agent/transport/TransportConnectionThread.java
@@ -16,6 +16,7 @@
*/
package org.cloud.sonic.agent.transport;
+import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.cloud.sonic.agent.tools.SpringTool;
@@ -31,7 +32,7 @@ public class TransportConnectionThread implements Runnable {
/**
* second
*/
- public static final long DELAY = 10;
+ public static final long DELAY = 30;
public static final String THREAD_NAME = "transport-connection-thread";
@@ -45,15 +46,19 @@ public class TransportConnectionThread implements Runnable {
public void run() {
Thread.currentThread().setName(THREAD_NAME);
if (TransportWorker.client == null) {
- if(!TransportWorker.isKeyAuth){
+ if (!TransportWorker.isKeyAuth) {
return;
}
//开发环境去掉/server
String url = String.format("ws://%s:%d/server/websockets/agent/%s",
- serverHost, serverPort, key).replace(":80/","/");
+ serverHost, serverPort, key).replace(":80/", "/");
URI uri = URI.create(url);
TransportClient transportClient = new TransportClient(uri);
transportClient.connect();
+ } else {
+ JSONObject ping = new JSONObject();
+ ping.put("msg", "ping");
+ TransportWorker.send(ping);
}
}
}