1

I am currently trying to do some datadriven testing with robot framework from a csv file, using a python customlibrary. I am running in some problems though, would be grateful if someone can point me in the right direction This is the error I am getting:

Resolving variable '${Tlogdata.0}' failed: SyntaxError: unexpected EOF while parsing (, line 1)

The csv I want to process currently has two records (I tried without, with single, and double codes):

1-KR8P27,11.0,1000
1-KR8P27,12.0,1001

I suspect the problem is with the customlibrary. I tried a lot in tweaking my code, but with what I found and my Python knowledge (that is admittably very basic) I cannot find any issue. This is what I currently have:

import csv


def read_csv_file(filename):
data = []
with open(filename,) as csvfile:
    reader = csv.reader(csvfile)
    for row in reader:
        data.append(row)
return data

I am using some more keywords in Robot Framework to use this customlibrary to fetch data from my csv. While I suspect that my python code is the problem and I double checked everything I might be overlooking something here instead:

In a datamanager keyword file I created the following Keyword:

 Get CSV Data
  [Arguments]  ${FilePath}
  ${Data} =  read csv file  ${FilePath}
  [Return]  ${Data}

Than I created a 'looping' keyword with a for loop:

Check multiple results
[Arguments]    ${tlogdatas}
FOR    ${tlogdata}    IN    ${tlogdatas}
    Check result TLOG3    ${tlogdata}

The keyword I call in my loop is already used in a testcase without a datadriven setup, and works. Only the variables are named differently to make it work with the datadriven thing. The keyword looks like this:

Check result TLOG3
  [Arguments]    ${Tlogdata}
  ${queryResults} =    query       select x_ord_pts_earn, total_amt from siebel.s_order where 
  contact_id = ${Tlogdata.0} and total_amt = ${Tlogdata.1}    and X_ORD_PTS_earn = ${Tlogdata.2}
  # log     @{queryResults[0][1]}
   ${dbvalue} =    set variable    ${queryResults}
   ${DB ordptsearn} =    set variable    ${queryResults[0][0]}
   ${DB contact_id} =    set variable    ${queryResults[0][1]}
   should be equal as integers     ${DB ordptsearn}     ${Tlogdata.2}
   should be equal as strings      ${DB contact_id}     ${Tlogdata.1}
    END

Than in my testcase I define a variable which fetches its results from my datamanager keyword and use the looping keyword to go through the csv values:

Check TLOG results from CSVFile
${Tlogdata} =    DataManager.Get CSV Data    ${TLOG_RESULTS_CSVPath}
 TLOG.Check multiple results    ${Tlogdata}

It might also be worth it to show the values from the csv that are fetched according to the report file:

${Tlogdata} = [["'1-KR8P27'", "'11.0'", "'1000'"], ["'1-KR8P27'", "'12.0'", "'1001'"]]

I hope this is somewhat clear, I understand it is quit some text. But I am not 100% sure where the problem is in my scripts. I hope someone can point me in the right direction.

0

1 Answer 1

1

You are indexing your list wrong. Instead of ${Tlogdata.0} you should have ${Tlogdata[0]}, etc..

Here is a quick example:

*** Test Cases ***
Test
    ${Tlogdata}=    Evaluate    [["'1-KR8P27'", "'11.0'", "'1000'"], ["'1-KR8P27'", "'12.0'", "'1001'"]]
    Log    ${Tlogdata[0]}
    Log    ${Tlogdata[1]}
    Log    ${Tlogdata[0][1]}
    Log    ${Tlogdata[1][1]}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.