Using .xlsx sheet name in datadriven robotframework

I am using datadriven library in robotframework the windows excel, the file format of .xlsx. I’ve two sheets in it, but when, I call the .xlsx file and with the sheet name, it not fetching file and sheet name

Test Script:
*** Settings ***
Library DataDriver file=C:\Users\u421643\AppData\Roaming\JetBrains\Aqua2024.3\extensions\com.intellij.database\ROBOT_FRAMEWORK\datadriven.xlsx
… sheet_name=Sheet1
Test Template Test Case Keyword 1

*** Keywords ***
Test Case Keyword 1
[Arguments] ${username} ${password}
Log ${username}
Log ${password}

*** Test Cases ***
The Test Execution ${username} ${password}
[Tags] data_driven

Data sheet:
For Sheet 1:

*** Test Cases *** ${username} ${password} [Tags] [Documentation]
Right user empty pass demo ${EMPTY} 1 This is a test case documentation of the first one.
Right user wrong pass demo FooBar 2,3,foo This test case has the Tags 2,3 and foo assigned.
${EMPTY} mode 1,2,3,4 This test case has a generated name based on template name.
${EMPTY} ${EMPTY}
${EMPTY} FooBar
FooBar mode
FooBar ${EMPTY}
FooBar FooBar

sheet 2:

*** Test Cases *** ${username} ${password} [Tags] [Documentation]
Test 2-sheet 1 2 3 4

the execution report
[ ERROR ] Calling method ‘_start_suite’ of listener ‘DataDriver’ failed: ImportError: Requirements (pandas, openpyxl) for XLSX support are not installed.
Use ‘pip install -U robotframework-datadriver[XLS]’ to install XLSX support.

And this error, did not gave a clue to you?

1 Like

I’ve installed these packages pip install -U robotframework-datadriver[XLS], pandas, openpyxl. Even after installation, I am facing this.

Hi Gunasekaran,

For some reason when datadriver library runs it’s not finding those packages.

this could be because you have multiple versions of python installed or it could be related to python virtual environments. You need to make sure when you run those pip commands to install those packages, you do it in the same python environment as what robot framework is in, but you haven’t given enough details about your environment for us to be able to tell what you need to do.

I hope this helps,

Dave.

1 Like