我有这样的问题。我在这里处理了一系列TestCase,其中mainreader.py文件中的一个脚本将始终按行分配一个用户名和密码。不幸的是我不知道该怎么做。每个TC何时调用主阅读器应从新行中获取2个变量。 到目前为止,我在此脚本中只进行了常规调用,但我不知道该怎么做。
manireader.py:
import csv
with open ('aisg_users.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=';')
line_count = 0
for row in csv_reader:
if line_count == 0:
aisg_username = row[0]
aisg_password = row[1]
print(aisg_username)
print(aisg_password)
line_count += 1
else:
exit()
print("Not FOUND")
有人解决了吗?
答案 0 :(得分:1)
public static Hashtable < String, String > getData(String testName, String sheetName, Xls_Reader xls) {
int testCaseStartIndex = 0;
for (int rNum = 1; rNum <= xls.getRowCount(sheetName); rNum++) {
if (testName.equals(xls.getCellData(sheetName, 0, rNum))) {
testCaseStartIndex = rNum;
break;
}
}
int colStartIndex = testCaseStartIndex + 1;
int cols = 1;
while (!xls.getCellData(sheetName, cols, colStartIndex).equals("")) {
cols++;
}
int dataStartIndex = testCaseStartIndex + 2;
int rows = 0;
while (!xls.getCellData(sheetName, 1, (dataStartIndex + rows)).equals("")) {
rows++;
}
Hashtable < String, String > table = null;
for (int rNum = dataStartIndex; rNum < (dataStartIndex + rows); rNum++) {
table = new Hashtable < String, String > ();
for (int cNum = 0; cNum < cols; cNum++) {
table.put(xls.getCellData(sheetName, cNum, colStartIndex), xls.getCellData(sheetName, cNum, rNum));
}
}
return table;
}
答案 1 :(得分:0)