Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Jun 7, 2023
1 parent dee777c commit 3637747
Showing 1 changed file with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1067,20 +1067,30 @@ public void toHandle(HandleContext handleContext, String params) throws Exceptio
handleContext.setE(e);
return;
}
int index = -1;
if (BytesTool.isInt(params)) {
index = BytesTool.getInt(params);
}
for (int i = 0; i < handles.size(); i++) {
try {
chromeDriver.switchTo().window(handles.get(i));
} catch (Exception ignored) {
}
if (i == index || chromeDriver.getTitle().equals(params)
|| chromeDriver.getCurrentUrl().equals(params)) {
int index = BytesTool.getInt(params);
if (index <= handles.size() - 1 || handles.get(index) != null) {
try {
chromeDriver.switchTo().window(handles.get(index));
} catch (Exception ignored) {
}
handleContext.setDetail("切换到Handle:" + params);
log.sendStepLog(StepType.INFO, "页面标题:" + chromeDriver.getTitle(), "");
return;
} else {
handleContext.setE(new SonicRespException(String.format("Handle list size is [%d], can not get the [%d] item", handles.size(), index)));
}
} else {
for (int i = 0; i < handles.size(); i++) {
try {
chromeDriver.switchTo().window(handles.get(i));
} catch (Exception ignored) {
}
if (chromeDriver.getTitle().contains(params) || chromeDriver.getCurrentUrl().contains(params)) {
handleContext.setDetail("切换到Handle:" + params);
log.sendStepLog(StepType.INFO, "页面标题:" + chromeDriver.getTitle(), "");
return;
}
}
}
handleContext.setE(new SonicRespException("Handle not found!"));
Expand Down Expand Up @@ -2372,7 +2382,7 @@ public void runStep(JSONObject stepJSON, HandleContext handleContext) throws Thr
case "setDefaultFindWebViewElementInterval" ->
setDefaultFindWebViewElementInterval(handleContext, step.getInteger("content"), step.getInteger("text"));
case "webElementScrollToView" ->
webElementScrollToView(handleContext, eleList.getJSONObject(0).getString("eleName"),
webElementScrollToView(handleContext, eleList.getJSONObject(0).getString("eleName"),
eleList.getJSONObject(0).getString("eleType"),
eleList.getJSONObject(0).getString("eleValue"));
case "isExistWebViewEle" ->
Expand Down

0 comments on commit 3637747

Please sign in to comment.