1:修复debug模式的bug

2:修复web测试中出现的一些bug
3:增加获取图片的接口
This commit is contained in:
seagull 2017-07-31 15:39:21 +08:00
parent 6ba7124606
commit 88344990b5
9 changed files with 66 additions and 36 deletions

View File

@ -37,7 +37,7 @@ public class TestCaseDebug{
* @param 用例版本号
* 用于在testlink上配置好用例参数后做单条用例调试
*/
public static void OneCaseDebug(String projectname,String testCaseExternalId,int version){
public static void OneCaseDebug(String projectname,String testCaseExternalId){
Map<String,String> variable = new HashMap<String,String>();
String packagename =null;
String functionname = null;
@ -245,7 +245,7 @@ public class TestCaseDebug{
Integer version = (Integer)entry.getValue();
try{
luckyclient.publicclass.LogUtil.APP.info("开始调用方法,项目名:"+projectname+",用例编号:"+testCaseExternalId+",用例版本:"+version);
OneCaseDebug(projectname,testCaseExternalId,version);
OneCaseDebug(projectname,testCaseExternalId);
}catch(Exception e){
continue;
}

View File

@ -1,7 +1,5 @@
package luckyclient.caserun.exinterface;
import luckyclient.caserun.exinterface.testlink.TestLinkCaseExecution;
public class ThreadForBatchCase extends Thread{
private String projectname;

View File

@ -48,8 +48,8 @@ public class ThreadForExecuteCase extends Thread{
String testnote = null;
int k = 0;
//进入循环解析单个用例所有步骤
System.out.println(caseid);
caselog.AddCaseDetail(taskid, caseid, "1", testcaseob.getName(), 4); //插入开始执行的用例
System.out.println(testcaseob.getSign());
caselog.AddCaseDetail(taskid, testcaseob.getSign(), "1", testcaseob.getName(), 4); //插入开始执行的用例
for(int i=0;i<steps.size();i++){
Map<String,String> casescript = InterfaceAnalyticCase.AnalyticCaseStep(testcaseob, steps.get(i),taskid); //解析单个步骤中的脚本
try{

View File

@ -47,7 +47,7 @@ public class ThreadForTestLinkExecuteCase extends Thread{
int k = 0;
//进入循环解析单个用例所有步骤
System.out.println(caseid);
caselog.AddCaseDetail(tastid, caseid, testcaseob.getVersion().toString(), testcaseob.getName(), 4); //插入开始执行的用例
caselog.AddCaseDetail(tastid, testcaseob.getFullExternalId(), testcaseob.getVersion().toString(), testcaseob.getName(), 4); //插入开始执行的用例
for(int i=0;i<testcaseob.getSteps().size();i++){
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.AnalyticCaseStep(testcaseob, i+1,tastid); //解析单个步骤中的脚本
try{

View File

@ -19,19 +19,19 @@ public class BaseWebDrive {
*/
public static Boolean WebScreenShot(WebDriver driver,String imgname) {
Boolean result = false;
String relativelyPath = System.getProperty("user.dir").substring(0, 3);
String relativelyPath = System.getProperty("user.dir");
// 对远程系统进行截图
driver = new Augmenter().augment(driver);
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(scrFile, new File(relativelyPath + "log\\ScreenShot\\" + imgname + ".png"));
FileUtils.copyFile(scrFile, new File(relativelyPath + "\\log\\ScreenShot\\" + imgname + ".png"));
} catch (IOException e) {
luckyclient.publicclass.LogUtil.APP.error("截图操作失败,抛出异常请查看日志...", e);
e.printStackTrace();
}
luckyclient.publicclass.LogUtil.APP
.info("已对当前界面进行截图操作,请前往服务器上查看...【" + relativelyPath + "log\\ScreenShot\\" + imgname + ".png】");
.info("已对当前界面进行截图操作,请前往服务器上查看...【" + relativelyPath + "\\log\\ScreenShot\\" + imgname + ".png】");
return result;
}

View File

@ -63,7 +63,7 @@ public class WebCaseExecution extends TestCaseExecution{
String checkproperty_value = params.get("checkproperty_value").toString();
WebElement we = isElementExist(wd, checkproperty, checkproperty_value);
if (we != null) {
if (null != we) {
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + "" + step.getStepnum()
+ "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
caselog.CaseLogDetail(taskid, testcase.getSign(), "在当前页面中找到预期结果中对象。当前步骤执行成功!",
@ -163,14 +163,8 @@ public class WebCaseExecution extends TestCaseExecution{
operation = params.get("operation");
operation_value = params.get("operation_value");
// 用例名称解析出现异常或是单个步骤参数解析异常
if (property_value != null && property.indexOf("解析异常") > -1) {
luckyclient.publicclass.LogUtil.APP.error("当前步骤解析出现异常或是对象为空!---"+property);
return "用例解析出错啦!";
}
// 处理值传递
if (property_value != null && property_value.indexOf("@") > -1 && property_value.indexOf("[@") < 0) {
if (null != property_value&& property_value.indexOf("@") > -1 && property_value.indexOf("[@") < 0) {
property_value = SettingParameter(property_value);
// 判断传参是否存在问题
if (property_value.indexOf("Set parameter error") > -1) {
@ -179,7 +173,7 @@ public class WebCaseExecution extends TestCaseExecution{
return "处理传参过程出错:" + property_value;
}
}
if (operation_value != null && operation_value.indexOf("@") > -1) {
if (null != operation_value&& operation_value.indexOf("@") > -1) {
operation_value = SettingParameter(operation_value);
if (operation_value.indexOf("Set parameter error") > -1) {
return "处理传参过程出错:" + property_value;
@ -196,7 +190,7 @@ public class WebCaseExecution extends TestCaseExecution{
try {
//调用接口用例
if(operation!=null&&operation_value!=null&&"runcase".equals(operation)){
if(null != operation&&null != operation_value&&"runcase".equals(operation)){
String temp[]=operation_value.split(",",-1);
String ex = TestCaseExecution.OneCaseExecuteForWebDriver(temp[0],taskid);
if(ex.indexOf("CallCase调用出错")<=-1&&ex.indexOf("解析出错啦!")<=-1&&ex.indexOf("匹配失败")<=-1){
@ -208,10 +202,10 @@ public class WebCaseExecution extends TestCaseExecution{
WebElement we = null;
if (property != null && property_value != null) { // 页面元素层
if (null != property && null != property_value) { // Ò³ÃæÔªËزã
we = isElementExist(wd, property, property_value);
// 判断此元素是否存在
if (we == null) {
if (null==we) {
luckyclient.publicclass.LogUtil.APP.error("定位对象失败isElementExist为null!");
return "isElementExist定位元素过程失败";
}
@ -225,7 +219,7 @@ public class WebCaseExecution extends TestCaseExecution{
} else {
result = EncapsulateOperation.ObjectOperation(wd, we, operation, operation_value, property, property_value);
}
} else if (property == null && operation != null) { // Driver层操作
} else if (null==property && null != operation) { // Driver²ã²Ù×÷
// 处理弹出框事件
if (operation.indexOf("alert") > -1){
result = EncapsulateOperation.AlertOperation(wd, operation);

View File

@ -36,7 +36,7 @@ public class WebDriverAnalyticCase {
LogOperation caselog = new LogOperation(); //初始化写用例结果以及日志模块
String resultstr = null;
try {
if(null==step.getPath()||step.getPath().indexOf("=")>-1){
if(null!=step.getPath()&&step.getPath().indexOf("=")>-1){
String property = step.getPath().substring(0, step.getPath().indexOf("="));
String property_value = step.getPath().substring(step.getPath().indexOf("=")+1, step.getPath().length());
@ -45,26 +45,33 @@ public class WebDriverAnalyticCase {
luckyclient.publicclass.LogUtil.APP.info("对象属性解析结果property:"+property.trim()+"; property_value:"+property_value.trim());
}
params.put("operation", step.getOperation().toLowerCase()); //set操作方法
if(null==step.getParameters()||"".equals(step.getParameters())){
params.put("property_value", step.getParameters()); //setÊôÐÔÖµ
if(null!=step.getParameters()&&!"".equals(step.getParameters())){
params.put("operation_value", step.getParameters()); //set属性值
}
luckyclient.publicclass.LogUtil.APP.info("对象操作解析结果operation:"+step.getOperation().toLowerCase()+"; operation_value:"+step.getParameters());
resultstr = step.getExpectedresult(); //获取预期结果字符串
//set预期结果
if("".equals(resultstr)){
if(null!=resultstr&&"".equals(resultstr)){
params.put("ExpectedResults", "");
}else{
}else if(null!=resultstr){
String ExpectedResults = SubComment(resultstr);
//处理check字段
if(ExpectedResults.indexOf("check(")>-1){
params.put("checkproperty", ExpectedResults.substring(ExpectedResults.indexOf("check(")+6, ExpectedResults.indexOf("=")));
params.put("checkproperty_value", ExpectedResults.substring(ExpectedResults.indexOf("=")+1, ExpectedResults.indexOf(")")));
params.put("checkproperty_value", ExpectedResults.substring(ExpectedResults.indexOf("=")+1, ExpectedResults.lastIndexOf(")")));
}
params.put("ExpectedResults", ExpectedResults);
luckyclient.publicclass.LogUtil.APP.info("预期结果解析ExpectedResults:"+ExpectedResults);
}
//set wait时间
if(null!=step.getAction()&&step.getAction().toLowerCase().indexOf("*wait")>-1){ //添加步骤之间等待时间
String action=step.getAction();
time=action.substring(0, action.toLowerCase().lastIndexOf("*wait"));
}
params.put("StepWait", time);
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!");
caselog.CaseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!","info",String.valueOf(step.getStepnum()),"");
@ -145,9 +152,6 @@ public class WebDriverAnalyticCase {
public static void main(String[] args){
// TODO Auto-generated method stub
/* Thread.sleep(20000);
System.out.println(test.stopServer());*/
}
}

View File

@ -13,5 +13,6 @@ public interface RunService extends Remote {
public String runcase(RunCaseEntity onecase) throws RemoteException;
public String runbatchcase(RunBatchCaseEntity batchcase) throws RemoteException;
public String getlogdetail(String storeName) throws RemoteException;
public byte[] getlogimg(String imgName) throws RemoteException;
public String uploadjar(byte[] fileContent,String name) throws RemoteException;
}

View File

@ -1,5 +1,6 @@
package rmi.serviceImpl;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
@ -120,6 +121,7 @@ public class RunServiceImpl extends UnicastRemoteObject implements RunService{
sb.append(str).append("\n");
}
bos.close();
System.out.println("服务端读取本地日志成功!");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@ -129,7 +131,38 @@ public class RunServiceImpl extends UnicastRemoteObject implements RunService{
}
/**
* 获取客户端日志
* 获取客户端截图
*
* @param request
* @param response
* @param storeName
* @param contentType
* @param realName
* @throws Exception
*/
public byte[] getlogimg(String imgName) throws RemoteException{
String ctxPath = System.getProperty("user.dir")+"\\log\\ScreenShot\\";
String downLoadPath = ctxPath+imgName;
byte[] b = null;
try {
File file = new File(downLoadPath);
b = new byte[(int) file.length()];
BufferedInputStream is = new BufferedInputStream(new FileInputStream(file));
is.read(b);
is.close();
System.out.println("服务端获取本地图片:"+downLoadPath);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return b;
}
/**
* 上传JAR包
*
* @param request
* @param response
@ -149,7 +182,9 @@ public class RunServiceImpl extends UnicastRemoteObject implements RunService{
file.createNewFile();
BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(file));
os.write(fileContent);
os.flush();
os.close();
System.out.println("服务端上传JAR包("+name+")到本地客户端lib目录成功!");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@ -163,8 +198,6 @@ public class RunServiceImpl extends UnicastRemoteObject implements RunService{
}
public static void main(String[] args) {
String ctxPath=System.getProperty("user.dir");
System.out.println(ctxPath);
public static void main(String[] args) throws RemoteException {
}
}