我还使用 Selenium webdriver 更新了测试链接
代码如下: -
public class appFunctions extends Keywords { // 在此处替换您的开发密钥
public static String DEV_KEY= "1eab09b6158d9df31e76142b85253243";
public static String SERVER_URL = "https://testlink.fondsdepotbank.de/testlink/lib/api/xmlrpc/v1/xmlrpc.php";
public static void clearXLResults() throws IOException
{
try
{
int testStepsRow=DriverScript.xlObj.getRowCount("TestSteps");
int controllerRow=DriverScript.xlObj.getRowCount("Controller");
//Clear previous results
for(int i=2;i<=testStepsRow;i++)
{
DriverScript.xlObj.setCellData("TestSteps",DriverScript.testStepsStatusCol, i, "");
}
for(int j=2;j<=controllerRow;j++)
{
DriverScript.xlObj.setCellData("Controller", DriverScript.controllerStatusCol, j, "");
}
}catch(Exception e)
{
e.printStackTrace();
log.writeLog("Unable to clear previous test results in excel");
}
}
public static void updateResultsTestLink() throws IOException
{
try
{
TestLinkAPIClient api=new TestLinkAPIClient(DEV_KEY, SERVER_URL);
String result;
//read controller status
int controllerRow=DriverScript.xlObj.getRowCount("Controller");
for(int k=2;k<=controllerRow;k++)
{
String currentRowStatus=DriverScript.xlObj.getCellData("Controller",DriverScript.controllerStatusCol,k);
String currentRowProject=DriverScript.xlObj.getCellData("Controller",DriverScript.controllerProjectCol,k);
String currentRowPlan=DriverScript.xlObj.getCellData("Controller",DriverScript.controllerPlanCol,k);
String currentRowBuild=DriverScript.xlObj.getCellData("Controller",DriverScript.controllerBuildCol,k);
String currentRowTCID=DriverScript.xlObj.getCellData("Controller",DriverScript.controllerTCIDCol,k);
if(currentRowStatus.equalsIgnoreCase("pass"))
{
result= TestLinkAPIResults.TEST_PASSED;
api.reportTestCaseResult(currentRowProject, currentRowPlan, currentRowTCID, currentRowBuild, null, result);
}
if(currentRowStatus.equalsIgnoreCase("fail"))
{
result= TestLinkAPIResults.TEST_FAILED;
api.reportTestCaseResult(currentRowProject, currentRowPlan, currentRowTCID, currentRowBuild, null, result);
}
}
}catch(Exception e)
{
e.printStackTrace();
log.writeLog("Unable to update results in Testlink");
}
}