Skip to content

Commit

Permalink
fix log and add appium setting 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Aug 2, 2022
1 parent d76741d commit 17eb8b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void sendKeys(String text, Integer frequency) throws SonicRespException {
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/session/" + sessionId + "/wda/keys")
.body(data.toJSONString()));
if (b.getErr() == null) {
log.info("send key {} .", new String(text.getBytes(StandardCharsets.UTF_8)));
log.info("send key {} .", text);
} else {
log.error("send key failed.");
throw new SonicRespException(b.getErr().getMessage());
Expand All @@ -244,7 +244,7 @@ public void setPasteboard(String contentType, String content) throws SonicRespEx
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/session/" + sessionId + "/wda/setPasteboard")
.body(data.toJSONString()));
if (b.getErr() == null) {
log.info("set pasteboard {} .", new String(content.getBytes(StandardCharsets.UTF_8)));
log.info("set pasteboard {} .", content);
} else {
log.error("set pasteboard failed.");
throw new SonicRespException(b.getErr().getMessage());
Expand Down Expand Up @@ -290,9 +290,9 @@ public void sendSiriCommand(String command) throws SonicRespException {
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/session/" + sessionId + "/wda/siri/activate")
.body(data.toJSONString()));
if (b.getErr() == null) {
log.info("send siri command: {}", new String(command.getBytes(StandardCharsets.UTF_8)));
log.info("send siri command: {}", command);
} else {
log.error("send siri command [{}] failed.", new String(command.getBytes(StandardCharsets.UTF_8)));
log.error("send siri command [{}] failed.", command);
throw new SonicRespException(b.getErr().getMessage());
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ public String getText() throws SonicRespException {
HttpUtil.createGet(wdaClient.getRemoteUrl() + "/session/"
+ wdaClient.getSessionId() + "/element/" + id + "/text"));
if (b.getErr() == null) {
String re = b.getValue().toString();
log.info("get {} text {}.", id, new String(re.getBytes(StandardCharsets.UTF_8)));
return re;
log.info("get {} text {}.", id, b.getValue().toString());
return b.getValue().toString();
} else {
log.error("get {} text failed.", id);
throw new SonicRespException(b.getErr().getMessage());
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/cloud/sonic/core/ios/IOSDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void testPasteboard() throws SonicRespException, InterruptedException {
iosDriver.findElement(IOSSelector.ACCESSIBILITY_ID, "WebDriverAgentRunner-Runner").click();
iosDriver.setPasteboard(PasteboardType.PLAIN_TEXT, text);
Thread.sleep(1000);
Assert.assertEquals(text.getBytes(StandardCharsets.UTF_8), new String(iosDriver.getPasteboard(PasteboardType.PLAIN_TEXT)).getBytes(StandardCharsets.UTF_8));
Assert.assertEquals(text, new String(iosDriver.getPasteboard(PasteboardType.PLAIN_TEXT), StandardCharsets.UTF_8));
iosDriver.pressButton(SystemButton.HOME);
}

Expand Down Expand Up @@ -224,7 +224,7 @@ public void testFindElement() throws SonicRespException, InterruptedException, I
Thread.sleep(2000);
iosDriver.findElement(IOSSelector.ACCESSIBILITY_ID, "搜索地点或地址").click();
WebElement w = iosDriver.findElement(IOSSelector.ACCESSIBILITY_ID, "搜索地点或地址");
String text = UUID.randomUUID() + "中文";
String text = UUID.randomUUID().toString().substring(0,6) + "中文";
w.sendKeys(text);
Assert.assertEquals(text, w.getText());
w.clear();
Expand Down

0 comments on commit 17eb8b8

Please sign in to comment.