Python 如何解决为单个测试用例分配行的问题

Python 如何解决为单个测试用例分配行的问题,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我有这样一个问题。我在这里处理的是一系列测试用例,其中mainreader.py文件中的一个脚本总是一行一行地分配一个用户名和密码。不幸的是,我不知道怎么做。每个TC调用mainreader时,应从新行中获取2个变量。 到目前为止,我在这个脚本中只有一个常规调用,但我不知道如何做 manireader.py: import csv with open ('aisg_users.csv') as csv_file: csv_reader = csv.reader(csv_fil

我有这样一个问题。我在这里处理的是一系列测试用例,其中mainreader.py文件中的一个脚本总是一行一行地分配一个用户名和密码。不幸的是,我不知道怎么做。每个TC调用mainreader时,应从新行中获取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")
有人解决过这样的问题吗


在下图中,我为每个凭证指定了唯一的标题名称,因此在我的自定义函数中,我将传递唯一的标题名称,该名称将标识行号,而行号+1是我的用户凭证位置

publicstatichashtablegetData(stringtestname,stringsheetname,Xls\u读取器Xls){
int testCaseStartIndex=0;
对于(int-rNum=1;rNum-table=null;
对于(int rNum=dataStartIndex;rNum<(dataStartIndex+行);rNum++){
table=新哈希表();
对于(int-cNum=0;cNum
Hi,您的意思是CSV文件由多个用户凭据组成,并且您希望为每个测试用例调用不同的凭据?如果这是您的期望值,则为每个凭据分配唯一的标头,并根据该标头在每个测试用例中获取凭据是的,这是我的期望值。您有任何示例吗?我在新通信中添加了pic请参阅
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;
}