Using Tags Declared in xls Datasheet

Basically exactly what the title says. I have a datasheet in excel that I am using to run my test cases. Right now it runs every case but I want to limit it to run specific ones. Datadriver says it has tag functionality but when I add it and try running with “-i sometag” it says that tag does not exist.

Has anyone else run into this issue? Seems like it should be possible im just not sure how to get my robot script to see those tags.

As written in the docs, you have to add the tag to be included to the template test as well:

This can be done by Default Tags or Force Tags In *** Settings *** or with [Tags] at the test case itself.

Also the data in excel need that tag im the [Tags] column.

So right now when i run the test in my report I can see that it sees the tags. If i run the test with include=foo up where I declare my datadriver library it only runs tests with the foo tag which is great but do you know if there is a way to be able to in my command line add -i foo and have it run just the foo tests?
Right now it says that foo isnt a tag. As far as my robot script would be concerned there is just one test case but datadriver runs all 8 of them. At the beginning of my testcase I have [Tags] FLAT.

Sorry if this response doesn’t make much sense have only been using this framework for a week.

If you have [Tags] flat, why do you not add foo to it?

Please post you robot code and your xls.

I think you are missing the point, that for --include you have to add the tags you want to include in the robot file! Not only in the xls file.

So just realized that my [Tags] flat is doing absolutely nothing from what i can tell. I was just looking through the examples from the datadriver github and gave it a shot. Otherwise this is the important bits of my code

Library          DataDriver  Datasheet/W2_Datasheet_End_To_End.xls     sheet_name=W2_Outsourcing
***  Test Cases ***
     Test Case

*** Keywords ***
Test case
      [Arguments]     ${Scenario} 	${json_fileName}	${registeredFiling_Count}    ${expectedStatusArrayRcdCount}   ${SUBDIR}  ${companionFileNamePrefix}
     [Tags] foo

and then my xls file is setup like

${Scenario}  ${json_fileName}  ${registeredFiling_Count}  ${expectedStatusArrayRcdCount}  ${SUBDIR}  ${companionFileNamePrefix}  [Tags]

foo should run 2 tests as 2 of them have that tag and when at the top i have include = foo it works fine but if i run it with --include foo it says nothing has that tag.

sorry for weird formatting on that message hopefully it still makes sense to read.

Yes it does.

Error is on my side!!!
i added that bug with the last release.

i try to fix it today!
Sorry for that.

Glad to hear I wasn’t doing something wrong! Glad I could bring it to attention. Will be keeping a look out for the fix! :slight_smile:

you can try out version 1.3.0

pip install robotframework-datadriver==1.3.0

That should work as well

@rgraham5616

It is not that easy to fix.
technically yes, but the question is: should the tags of the template be added all to the data-driven tests?

It’s hard to say I guess. In my personal use cases I would want both tags declared in the .robot file and the ones in the excel sheet to work. I think both serve a purpose depending on the use case.

If tags in the excel sheet don’t work then there is no point having them as a feature but also people should have the option of declaring the tags as normal.

That’s my perspective on the question posed in the GitHub link

Hi Guys

I am missing something here and I don’t know what is wrong. I hope somebody can help

I need to include and excluse tests using tags defined in the csv file

I have a csv file with Tags and a robot file (see below)and when I run the tests

when I run the test as below everything is fine
python -m robot --report NONE --outputdir output --logtitle "Task log" --exclude 1 DataDriven.robot

But when I run the test as below I get an error
python -m robot --report NONE --outputdir output --logtitle "Task log" --include 1 DataDriven.robot
[ ERROR ] Suite ‘DataDriven’ contains no tests matching tag ‘1’.

But when I run the test as below I get an error
python -m robot --report NONE --outputdir output --logtitle "Task log" --exclude 1 --include foo DataDriven.robot

[ ERROR ] Suite ‘DataDriven’ contains no tests matching tag ‘foo’ and not matching tag ‘1’.

I have following files:


  1. DataDriven.csv
    *** 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
    empty user right pw;${EMPTY};mode;1,2,3,4;This test case has a generated name based on template name.
    empty user empty pw;${EMPTY};${EMPTY};;
    empty user foobar pw;${EMPTY};FooBar;;
    foobar user mode pw;FooBar;mode;foo,1;
    foobar user empty pw;FooBar;${EMPTY};foo;
    foobar user foobar pw;FooBar;FooBar;foo,2;

  1. DataDriven.robot
    *** Settings ***
    Library DataDriver

    Suite Setup Open my Browser
    Test Setup Open Login Page
    Test Template Invalid Login
    Suite Teardown Close Browsers

    *** Test Cases *** ${username} ${password}
    Login with user ‘${username}’ and password ‘${password}’ Default UserData

    *** Keywords ***
    Invalid login
    [Arguments] ${username} ${password}
    Input username ${username}
    Input pwd ${password}
    click login button
    Error page should be visible

    Open my Browser
    Log To Console Open my Browser

    Open Login Page
    Log To Console Open Login Page

    Close Browsers
    Log To Console Close Browsers

    Input username
    [Arguments] ${username}
    Log To Console Input username : ${username}

    Input pwd
    [Arguments] ${password}
    Log To Console Input pwd ${password}

    click login button
    Log To Console click login button

    Error page should be visible
    Log To Console Error page should be visible