如何创建 C# OTA 代码以根据 ALM 中的测试计划中 Excel 中提供的路径创建文件夹你能帮我解决这个问题吗?

问题描述

我已尝试使用以下代码在使用 OTA 的测试计划中创建文件夹结构,但无法这样做.. 我收到消息说未找到 Node.. 请帮我提供正确的代码

Folderpath =  Subject\UAT\UAT2\Testcases

private void Upload_Test_Click(object sender,EventArgs e)
{
if (File_path.Text == null)
{
MetroMessageBox.Show(this,"Please Select a Valid File","File",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
string path = File_path.Text;
FileInfo fileinfo = new FileInfo(path);
ExcelPackage excel = new ExcelPackage(fileinfo);
var worksheet = excel.Workbook.Worksheets["Test Cases"];
//get te number of rows and columns in the sheet
int rows = worksheet.Dimension.Rows;
int columns = worksheet.Dimension.Columns;
int i = 2;
//loop through the worksheet rows and columsn
while (i <= rows)
{
testfact = (ITestFactory2)LoginForm.qctd.TestFactory;
TreeManager treemgr = LoginForm.qctd.TreeManager;
SysTreeNode tstrr = treemgr.NodeByPath[worksheet.Cells[i,1].Value.ToString()];
tstrr.AddNode(worksheet.Cells[i,2].Value.ToString());
tstrr.Post();
tstrr.Refresh();
List testlist = tstrr.NewList();
foreach(Test tset in testlist)
{
tset["TS_NAME"] = worksheet.Cells[i,2].Value.ToString();
tset.Post();
tset.Refresh();
}
i = i + 1;
}
MessageBox.Show("Test Uplaoded successfully");
}

解决方法

如果您添加有关错误的更多详细信息(例如发生错误的行),将会很有帮助。我假设您在调用 treemgr.NodeByPath 时得到它,这意味着没有具有此类路径的文件夹 - 检查您的 ALM 文件夹或调整您的脚本以创建丢失的文件夹