Skip to content

Commit

Permalink
fix: new apk
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Nov 23, 2022
1 parent b2a6d4a commit a61f779
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public AndroidElementImpl(String id, UiaClient uiaClient) {
public void click() throws SonicRespException {
uiaClient.checkSessionId();
BaseResp b = uiaClient.getRespHandler().getResp(
HttpUtil.createPost(uiaClient.getRemoteUrl() + "/wd/hub/session/"
HttpUtil.createPost(uiaClient.getRemoteUrl() + "/session/"
+ uiaClient.getSessionId() + "/element/" + id + "/click"));
if (b.getErr() == null) {
logger.info("click element %s.", id);
Expand All @@ -65,7 +65,7 @@ public void sendKeys(String text, boolean isCover) throws SonicRespException {
data.put("text", text);
data.put("replace", isCover);
BaseResp b = uiaClient.getRespHandler().getResp(
HttpUtil.createPost(uiaClient.getRemoteUrl() + "/wd/hub/session/"
HttpUtil.createPost(uiaClient.getRemoteUrl() + "/session/"
+ uiaClient.getSessionId() + "/element/" + id + "/value")
.body(data.toJSONString()), 60000);
if (b.getErr() == null) {
Expand All @@ -80,7 +80,7 @@ public void sendKeys(String text, boolean isCover) throws SonicRespException {
public void clear() throws SonicRespException {
uiaClient.checkSessionId();
BaseResp b = uiaClient.getRespHandler().getResp(
HttpUtil.createPost(uiaClient.getRemoteUrl() + "/wd/hub/session/"
HttpUtil.createPost(uiaClient.getRemoteUrl() + "/session/"
+ uiaClient.getSessionId() + "/element/" + id + "/clear"), 60000);
if (b.getErr() == null) {
logger.info("clear %s.", id);
Expand All @@ -94,7 +94,7 @@ public void clear() throws SonicRespException {
public String getText() throws SonicRespException {
uiaClient.checkSessionId();
BaseResp b = uiaClient.getRespHandler().getResp(
HttpUtil.createGet(uiaClient.getRemoteUrl() + "/wd/hub/session/"
HttpUtil.createGet(uiaClient.getRemoteUrl() + "/session/"
+ uiaClient.getSessionId() + "/element/" + id + "/text"));
if (b.getErr() == null) {
logger.info("get %s text %s.", id, b.getValue().toString());
Expand All @@ -109,7 +109,7 @@ public String getText() throws SonicRespException {
public String getAttribute(String name) throws SonicRespException {
uiaClient.checkSessionId();
BaseResp b = uiaClient.getRespHandler().getResp(
HttpUtil.createGet(uiaClient.getRemoteUrl() + "/wd/hub/session/"
HttpUtil.createGet(uiaClient.getRemoteUrl() + "/session/"
+ uiaClient.getSessionId() + "/element/" + id + "/attribute/" + name));
if (b.getErr() == null) {
logger.info("get %s attribute %s result %s.", id, name, b.getValue().toString());
Expand All @@ -124,7 +124,7 @@ public String getAttribute(String name) throws SonicRespException {
public ElementRect getRect() throws SonicRespException {
uiaClient.checkSessionId();
BaseResp b = uiaClient.getRespHandler().getResp(
HttpUtil.createGet(uiaClient.getRemoteUrl() + "/wd/hub/session/"
HttpUtil.createGet(uiaClient.getRemoteUrl() + "/session/"
+ uiaClient.getSessionId() + "/element/" + id + "/rect"));
if (b.getErr() == null) {
ElementRect elementRect = JSON.parseObject(b.getValue().toString(), ElementRect.class);
Expand All @@ -140,7 +140,7 @@ public ElementRect getRect() throws SonicRespException {
public byte[] screenshot() throws SonicRespException {
uiaClient.checkSessionId();
BaseResp b = uiaClient.getRespHandler().getResp(
HttpUtil.createGet(uiaClient.getRemoteUrl() + "/wd/hub/session/"
HttpUtil.createGet(uiaClient.getRemoteUrl() + "/session/"
+ uiaClient.getSessionId() + "/element/" + id + "/screenshot"), 60000);
if (b.getErr() == null) {
logger.info("get element %s screenshot.", id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void setSessionId(String sessionId) {
public void newSession(JSONObject capabilities) throws SonicRespException {
JSONObject data = new JSONObject();
data.put("capabilities", capabilities);
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/wd/hub/session").body(data.toJSONString()));
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/session").body(data.toJSONString()));
if (b.getErr() == null) {
SessionInfo sessionInfo = JSON.parseObject(b.getValue().toString(), SessionInfo.class);
setSessionId(sessionInfo.getSessionId());
Expand All @@ -137,7 +137,7 @@ public void newSession(JSONObject capabilities) throws SonicRespException {
@Override
public void closeSession() throws SonicRespException {
checkSessionId();
respHandler.getResp(HttpUtil.createRequest(Method.DELETE, remoteUrl + "/wd/hub/session/" + sessionId));
respHandler.getResp(HttpUtil.createRequest(Method.DELETE, remoteUrl + "/session/" + sessionId));
logger.info("close session successful!");
}

Expand All @@ -153,7 +153,7 @@ public void checkSessionId() throws SonicRespException {
public WindowSize getWindowSize() throws SonicRespException {
if (size == null) {
checkSessionId();
BaseResp b = respHandler.getResp(HttpUtil.createGet(remoteUrl + "/wd/hub/session/" + sessionId + "/window/:windowHandle/size"));
BaseResp b = respHandler.getResp(HttpUtil.createGet(remoteUrl + "/session/" + sessionId + "/window/:windowHandle/size"));
if (b.getErr() == null) {
size = JSON.parseObject(b.getValue().toString(), WindowSize.class);
logger.info("get window size %s.", size.toString());
Expand All @@ -171,7 +171,7 @@ public void sendKeys(String text, boolean isCover) throws SonicRespException {
JSONObject data = new JSONObject();
data.put("text", text);
data.put("replace", isCover);
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/wd/hub/session/" + sessionId + "/keys")
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/session/" + sessionId + "/keys")
.body(data.toJSONString()));
if (b.getErr() == null) {
logger.info("send key %s.", text);
Expand All @@ -187,7 +187,7 @@ public void setPasteboard(String contentType, String content) throws SonicRespEx
JSONObject data = new JSONObject();
data.put("contentType", contentType.toUpperCase(Locale.ROOT));
data.put("content", Base64.getEncoder().encodeToString(content.getBytes(StandardCharsets.UTF_8)));
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/wd/hub/session/" + sessionId + "/appium/device/set_clipboard")
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/session/" + sessionId + "/appium/device/set_clipboard")
.body(data.toJSONString()));
if (b.getErr() == null) {
logger.info("set pasteboard %s.", content);
Expand All @@ -202,7 +202,7 @@ public byte[] getPasteboard(String contentType) throws SonicRespException {
checkSessionId();
JSONObject data = new JSONObject();
data.put("contentType", contentType.toUpperCase(Locale.ROOT));
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/wd/hub/session/" + sessionId + "/appium/device/get_clipboard")
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/session/" + sessionId + "/appium/device/get_clipboard")
.body(data.toJSONString()));
if (b.getErr() == null) {
byte[] result = Base64.getMimeDecoder().decode(b.getValue().toString());
Expand All @@ -217,7 +217,7 @@ public byte[] getPasteboard(String contentType) throws SonicRespException {
@Override
public String pageSource() throws SonicRespException {
checkSessionId();
BaseResp b = respHandler.getResp(HttpUtil.createGet(remoteUrl + "/wd/hub/session/" + sessionId + "/source"), 60000);
BaseResp b = respHandler.getResp(HttpUtil.createGet(remoteUrl + "/session/" + sessionId + "/source"), 60000);
if (b.getErr() == null) {
logger.info("get page source.");
return b.getValue().toString();
Expand Down Expand Up @@ -250,7 +250,7 @@ public AndroidElement findElement(String selector, String value, Integer retry,
JSONObject data = new JSONObject();
data.put("strategy", selector);
data.put("selector", value);
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/wd/hub/session/" + sessionId + "/element")
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/session/" + sessionId + "/element")
.body(data.toJSONString()));
if (b.getErr() == null) {
logger.info("find element successful.");
Expand Down Expand Up @@ -292,7 +292,7 @@ public List<AndroidElement> findElementList(String selector, String value, Integ
JSONObject data = new JSONObject();
data.put("strategy", selector);
data.put("selector", value);
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/wd/hub/session/" + sessionId + "/elements")
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/session/" + sessionId + "/elements")
.body(data.toJSONString()));
if (b.getErr() == null) {
logger.info("find elements successful.");
Expand Down Expand Up @@ -329,7 +329,7 @@ public List<AndroidElement> findElementList(String selector, String value, Integ
public byte[] screenshot() throws SonicRespException {
checkSessionId();
BaseResp b = respHandler.getResp(
HttpUtil.createGet(remoteUrl + "/wd/hub/session/" + sessionId + "/screenshot"), 60000);
HttpUtil.createGet(remoteUrl + "/session/" + sessionId + "/screenshot"), 60000);
if (b.getErr() == null) {
logger.info("get screenshot.");
return Base64.getMimeDecoder().decode(b.getValue().toString());
Expand All @@ -344,7 +344,7 @@ public void setAppiumSettings(JSONObject settings) throws SonicRespException {
checkSessionId();
JSONObject data = new JSONObject();
data.put("settings", settings);
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/wd/hub/session/" + sessionId + "/appium/settings")
BaseResp b = respHandler.getResp(HttpUtil.createPost(remoteUrl + "/session/" + sessionId + "/appium/settings")
.body(data.toJSONString()));
if (b.getErr() == null) {
logger.info("set appium settings %s.", settings.toJSONString());
Expand Down

0 comments on commit a61f779

Please sign in to comment.