[bug] 点击控件时提示: org.cloud.sonic.driver.common.tool.SonicRespException: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.. Try changing the 'enforceXPath1' driver setting to 'true' in order to workaround the problem.","rid":0,"udId":"R5CW8091P0X","status":3,"cid":0
Closed this issue · 11 comments
Search before asking
- I searched in the issue and found nothing similar. | 我查找了并确认issue列表无相似报告。
Sonic version
2.7.1
Deploy platform
mac os
Minimal reproduce step
操作点击控件失败,提示:
{"msg":"step","des":"点击Android-开播-video 类型 Effects 异常!","log":"点击xpath: //android.widget.TextView[contains(@text,'Effects')]","rid":0,"udId":"R5CW8091P0X","status":4,"cid":0}
{"msg":"step","des":"","log":"异常信息: org.cloud.sonic.driver.common.tool.SonicRespException: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.. Try changing the 'enforceXPath1' driver setting to 'true' in order to workaround the problem.","rid":0,"udId":"R5CW8091P0X","status":3,"cid":0}
Are you willing to submit a PR?
- I'm willing to submit a PR! | 我将发起PR!
尝试修改代码:
包名:org.cloud.sonic.agent.tests.handlers
类名:AndroidStepHandler
方法:startAndroidDriver
public void startAndroidDriver(IDevice iDevice, int uiaPort) throws Exception {
this.iDevice = iDevice;
int retry = 0;
Exception out = null;
// 设置 Appium 服务器的地址和端口
String appiumServerUrl = "http://127.0.0.1:" + uiaPort;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("enforceXPath1", true);
JSONObject capJsonObj = (JSONObject) JSONObject.toJSON(capabilities);
while (retry <= 4) {
try {
androidDriver = new AndroidDriver("http://127.0.0.1:" + uiaPort,capJsonObj);
break;
} catch (Exception e) {
log.sendStepLog(StepType.WARN, String.format("连接 UIAutomator2 Server 失败!重试第 %d 次...", retry + 1), "");
out = e;
}
retry++;
Thread.sleep(2000);
}
if (androidDriver == null) {
log.sendStepLog(StepType.ERROR, "连接 UIAutomator2 Server 失败!", "");
setResultDetailStatus(ResultDetailStatus.FAIL);
throw out;
}
androidDriver.getUiaClient().setGlobalTimeOut(60000);
log.sendStepLog(StepType.PASS, "连接 UIAutomator2 Server 成功", "");
// 获取屏幕的宽度与高度
String screenSizeInfo = AndroidDeviceBridgeTool.getScreenSize(iDevice);
String[] winSize = screenSizeInfo.split("x");
screenWidth = BytesTool.getInt(winSize[0]);
screenHeight = BytesTool.getInt(winSize[1]);
log.androidInfo("Android", iDevice.getProperty(IDevice.PROP_BUILD_VERSION),
iDevice.getSerialNumber(), iDevice.getProperty(IDevice.PROP_DEVICE_MANUFACTURER),
iDevice.getProperty(IDevice.PROP_DEVICE_MODEL),
screenSizeInfo);
}
仍然有相同的提示
你是用sonic的uia2还是自己的
Sonic自带的。
APP页面相比原来增加了一些日志输出,打印CPU内存这些信息,然后就出现定位不到的情况了,提示上面的信息
emmm没见过,我看看
似乎是信息过长了,你这个页面很多控件吗?或者文字内容很长?
不是,没有多少控件
你有二开的能力吗?试下下面这段加到这里最后面
JSONObject settings = new JSONObject();
settings.put("enforceXPath1", true);
androidDriver.setAppiumSettings(settings);
如果没有代码能力的话,我可以下版本加个功能进去给你试下
好的,非常感谢。我加一下试试