Error Reading Variables from Excel file

I am following the same method installing the Excel Package
pip install -U robotframework-datadriver[XLS]
then adding the robotframework-datadriver in the settings of Pycharm
PATH: D:\AUTO from where i am running the script.
below is my code

*** settings ***
Library    SeleniumLibrary
Test Template   GeneralInformationPage
Library    XML
Library    Screenshot
Library     DataDriver      ../AUTO/wsrfr/Testscripts/Data/Data1.xlsx
Resource    ../../../newproduct/TestScripts/Pages/Common.robot
Resource    ../../../newproduct/TestScripts/Pages/LoginPage.robot
Resource    ../../Testscripts/Pages/GendralInfo.robot
*** Variables ***
${data_file}    Data1.xlsx

*** test cases ***
LoginPage
       LoginPage.LogintoWoodruffPage
Navigate_to_ProductConfigure
      Common.NavigatetoRFR
      GeneralInformationPage
      [Teardown]    Close Browser
*** Keywords ***
GeneralInformationPage
    [Arguments]     ${NamedInsured}   # NameInsured is declared in Excel
    Wait For Condition	return document.readyState == "complete"
    Click Element    ${RenewalBtn}
    Wait For Condition	return document.readyState == "complete"
    log to console   General Information Started
    Input Text    ${NamedInsuredinp}    ${NamedInsured}

ERROR

PS D:\AUTO> python -m robot .\wsrfr\Testscripts\specs\wsrfr.robot
==============================================================================
Wsrfr                                                                         
==============================================================================
[ ERROR ] [ DataDriver ] Error in robot file:
  File "D:\AUTO\wsrfr\Testscripts\specs\wsrfr.robot", line 0
[ ERROR ] Calling method '_start_suite' of listener 'DataDriver' failed: FileNotFoundError: File attribute was empty. Tried to find D:\AUTO\wsrfr\Testscripts\specs\wsrfr.csv but file does not exist. If no file validation is required, set file_search_strategy=None.

This file is not listed in your code, so the error does not match your example test. The file is a .csv and not an .xls.

You could try to use absolute paths, or starting from ${CURDIR}, the (…) you are using, are not correct, they should be (…).

Conclusion, you wrote some example code that is not correct. If you did create some reproducible code, we could try to run it and better help you.

1 Like

The error was:

When you do not set the file attribute of DataDriver, it by default tries to find a csv file that is named as your robot file in the same directory.

Your File D:\AUTO\wsrfr\Testscripts\specs\wsrfr.robot leads to D:\AUTO\wsrfr\Testscripts\specs\wsrfr.csv as default file.

One thing that is “wrong” but probably has nothing to do with that error:
Your test has content. When you use Test Template everything that is inside your test case, is interpreted as data and not as keywords. So only the template keyword is executed.
DataDriver will anyway delete everything except the Teardown.

Still for some reason it does not take that line:

Library     DataDriver      ../AUTO/wsrfr/Testscripts/Data/Data1.xlsx

You should check if there is any weird characters between the DataDriver and the path.

1 Like