提交 3a6c3ae1 authored 作者: 黄承天's avatar 黄承天

[feature]

增加mouseDown mouseMove mouseUp三种操作类型的处理 未识别类型的步骤将从总数中剔除
上级 b583d01b
...@@ -26,6 +26,12 @@ public interface CommandType { ...@@ -26,6 +26,12 @@ public interface CommandType {
String CLICK = "click"; String CLICK = "click";
String MOUSE_DOWN = "mouseDownAt";
String MOUSE_MOVE = "mouseMoveAt";
String MOUSE_UP = "mouseUpAt";
String DOUBLE_CLICK = "doubleClick"; String DOUBLE_CLICK = "doubleClick";
String CLOSE = "close"; String CLOSE = "close";
......
...@@ -69,7 +69,7 @@ public class SeleniumExecutor { ...@@ -69,7 +69,7 @@ public class SeleniumExecutor {
private Date endTime = null; private Date endTime = null;
private Long costTime = 0L; private Long costTime = -1L;
private Integer finished = 0; private Integer finished = 0;
...@@ -98,7 +98,6 @@ public class SeleniumExecutor { ...@@ -98,7 +98,6 @@ public class SeleniumExecutor {
name = testCase.getName(); name = testCase.getName();
this.params = params; this.params = params;
List<Command> commands = testCase.getCommands(); List<Command> commands = testCase.getCommands();
total = commands.size();
//根据浏览器 获取driver //根据浏览器 获取driver
this.browser = browser; this.browser = browser;
if (nonNull(headless)) { if (nonNull(headless)) {
...@@ -111,6 +110,8 @@ public class SeleniumExecutor { ...@@ -111,6 +110,8 @@ public class SeleniumExecutor {
Step step = actCommand(command); Step step = actCommand(command);
if (nonNull(step)) { if (nonNull(step)) {
steps.add(step); steps.add(step);
} else {
total--;
} }
finished = steps.size(); finished = steps.size();
Report report = getReport(); Report report = getReport();
...@@ -230,7 +231,7 @@ public class SeleniumExecutor { ...@@ -230,7 +231,7 @@ public class SeleniumExecutor {
success = true; success = true;
break; break;
case CLICK: case CLICK:
content = format("点击元素:[%s]", target); content = format("单击:[%s]", target);
element = locateElement(target); element = locateElement(target);
if (isNull(element)) { if (isNull(element)) {
element = getElement(targets); element = getElement(targets);
...@@ -255,7 +256,7 @@ public class SeleniumExecutor { ...@@ -255,7 +256,7 @@ public class SeleniumExecutor {
} }
break; break;
case DOUBLE_CLICK: case DOUBLE_CLICK:
content = format("双击元素:[%s]", target); content = format("双击:[%s]", target);
element = locateElement(target); element = locateElement(target);
if (isNull(element)) { if (isNull(element)) {
element = getElement(targets); element = getElement(targets);
...@@ -279,6 +280,78 @@ public class SeleniumExecutor { ...@@ -279,6 +280,78 @@ public class SeleniumExecutor {
success = false; success = false;
} }
break; break;
case MOUSE_DOWN:
content = format("长单击:[%s]", target);
element = locateElement(target);
if (isNull(element)) {
element = getElement(targets);
}
if (nonNull(element)) {
boolean newWindow = nonNull(command.getOpensWindow()) && command.getOpensWindow();
if (newWindow) {
seleniumHelper.setHistoryHandles(driver.getWindowHandles());
}
new Actions(driver).moveToElement(element).clickAndHold().perform();
seleniumHelper.waitSomeTime();
costTime = System.currentTimeMillis() - stepStartTime;
success = true;
if (newWindow) {
seleniumHelper.getHandleMap().put(command.getWindowHandleName(), getWindowHandle());
}
} else {
message = "无法定位该元素";
costTime = System.currentTimeMillis() - stepStartTime;
success = false;
}
break;
case MOUSE_MOVE:
content = format("鼠标移动至:[%s]", target);
element = locateElement(target);
if (isNull(element)) {
element = getElement(targets);
}
if (nonNull(element)) {
boolean newWindow = nonNull(command.getOpensWindow()) && command.getOpensWindow();
if (newWindow) {
seleniumHelper.setHistoryHandles(driver.getWindowHandles());
}
new Actions(driver).moveToElement(element).perform();
seleniumHelper.waitSomeTime();
costTime = System.currentTimeMillis() - stepStartTime;
success = true;
if (newWindow) {
seleniumHelper.getHandleMap().put(command.getWindowHandleName(), getWindowHandle());
}
} else {
message = "无法定位该元素";
costTime = System.currentTimeMillis() - stepStartTime;
success = false;
}
break;
case MOUSE_UP:
content = format("停止长按:[%s]", target);
element = locateElement(target);
if (isNull(element)) {
element = getElement(targets);
}
if (nonNull(element)) {
boolean newWindow = nonNull(command.getOpensWindow()) && command.getOpensWindow();
if (newWindow) {
seleniumHelper.setHistoryHandles(driver.getWindowHandles());
}
new Actions(driver).moveToElement(element).release().perform();
seleniumHelper.waitSomeTime();
costTime = System.currentTimeMillis() - stepStartTime;
success = true;
if (newWindow) {
seleniumHelper.getHandleMap().put(command.getWindowHandleName(), getWindowHandle());
}
} else {
message = "无法定位该元素";
costTime = System.currentTimeMillis() - stepStartTime;
success = false;
}
break;
case SELECT: case SELECT:
String label = seleniumHelper.getValue(value); String label = seleniumHelper.getValue(value);
content = format("下拉框选择:[%s]", label); content = format("下拉框选择:[%s]", label);
...@@ -462,8 +535,8 @@ public class SeleniumExecutor { ...@@ -462,8 +535,8 @@ public class SeleniumExecutor {
startTime = null; startTime = null;
endTime = null; endTime = null;
costTime = -1L; costTime = -1L;
finished = -1; finished = 0;
total = -1; total = 0;
steps.clear(); steps.clear();
if (nonNull(params)) { if (nonNull(params)) {
params.clear(); params.clear();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论