Forum Discussion

MarkSchofer's avatar
MarkSchofer
Frequent Contributor
4 years ago

Data Driven Loops

They seem easy enough. Read a CSV file (I have done that). The parameters are for only an individual cell and I am not able to get the looping working

here is the script version.
def Loopy():
Check_V = ""
Check_Amt_V = ""
Check_Date_V = ""
Project.Variables.LoopD.Reset()
RecordIdx = 1
while RecordIdx <= 105:
#Derive DataLoop
#Retrieves the Excel cell value and saves it as Last Operation Result.
#LastResult = Excel.Open("C:\\Smartbear\\Documentation\\Formatted Pension.xlsx").SheetByTitle["Pension Formatted"].CellByName["AB1"].Value
#Check_Amt_V = LastResult
#Posts an information message to the test log.
Log.Message(Project.Variables.LoopD, "HappyBirthday")
#Retrieves the Excel cell value and saves it as Last Operation Result.
LastResult1 = Excel.Open("C:\\Smartbear\\Documentation\\Formatted Pension.xlsx").SheetByTitle["Pension Formatted"].CellByName["AB1"].Value
#Derive CheckAmt
Check_Amt_V = LastResult1
#Posts an information message to the test log.
Log.Message(Check_Amt_V, "")
#Derive Payee
#Retrieves the Excel cell value and saves it as Last Operation Result.
LastResult2 = Excel.Open("C:\\Smartbear\\Documentation\\Formatted Pension.xlsx").SheetByTitle["Pension Formatted"].CellByName["A1"].Value
Check_V = LastResult2
#Posts an information message to the test log.
Log.Message(Check_V, "")
#Opens the specified URL in a running instance of the specified browser.
#Browsers.Item[btIExplorer].Navigate("https://qat1.q.pers.state.or.us/Clarety/SANavigator.do?event=R_GO")
#Derive Check Date
#Retrieves the Excel cell value and saves it as Last Operation Result.
LastResult3 = Excel.Open("C:\\Smartbear\\Documentation\\Formatted Pension.xlsx").SheetByTitle["Pension Formatted"].CellByName["AA1"].Value
Check_Date_V = LastResult3
#Posts an information message to the test log.
Log.Message(Check_Date_V, "")
Project.Variables.LoopD.Next()
RecordIdx = RecordIdx + 1

    • MarkSchofer's avatar
      MarkSchofer
      Frequent Contributor

      Yes that is a perfect response given it is a Monday here in the Pacific North West - That is pretty darn easy and now I have to the 23bit 64 bit matching game. I am going to give it a try with a CSV file.   It recommends a 32 bit version of TC or a 64 bit version of excel.    

      **bleep** that was really easy. I did download the driver and it worked like a charm. Yes I was working far too hard.

      • MarkSchofer's avatar
        MarkSchofer
        Frequent Contributor

        Here is my solution

         

        def CurDriverExample():
        # Creates a driver
        DDT.ExcelDriver("C:\Smartbear\Documentation\FormattedPension.xlsx", "FP")
        # Iterates through records
        while not DDT.CurrentDriver.EOF():
        # Gets a value from the storage and posts it to the log
        count = DDT.CurrentDriver.ColumnCount
        for i in range (0, count):
        column = DDT.CurrentDriver.ColumnName[i]
        #Log.Message(DDT.CurrentDriver.Value[1])
        aqTestCase.Begin("GetCheckNumber")
        Log.Message(DDT.CurrentDriver.Value[2])
        aqTestCase.End()
        #Log.Message(DDT.CurrentDriver.Value[3])
        aqTestCase.Begin("GetCheckDate")
        Log.Message(DDT.CurrentDriver.Value[26])
        aqTestCase.End()
        aqTestCase.Begin("GetCheckAmt")
        Log.Message(DDT.CurrentDriver.Value[27])
        aqTestCase.End()
        DDT.CurrentDriver.Next()
        # Closes the driver
        DDT.CloseDriver(DDT.CurrentDriver.Name)