# Using Tags Declared in xls Datasheet

**URL:** <https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278>\
**Category:** DataDriver\
**Created:** [16 August 2021 17:38 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278 "2021-08-16T17:38:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgraham5616](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rgraham5616](https://forum.robotframework.org/u/rgraham5616)\
**Post date:** [16 August 2021 17:38 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/1 "2021-08-16T17:38:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![René](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ren%C3%A9/32/7_2.png) [@René](https://forum.robotframework.org/u/Ren%C3%A9)\
**Post date:** [16 August 2021 18:46 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/2 "2021-08-16T18:46:09Z")

</div>

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

> **[GitHub - Snooz82/robotframework-datadriver: Library to provide Data-Driven...](https://github.com/Snooz82/robotframework-datadriver#filtering-with-tags)**
>
> Library to provide Data-Driven testing with CSV tables to Robot Framework - GitHub - Snooz82/robotframework-datadriver: Library to provide Data-Driven testing with CSV tables to Robot Framework

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.

---

<div class="post-metadata">

**Author:** ![rgraham5616](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rgraham5616](https://forum.robotframework.org/u/rgraham5616)\
**Post date:** [16 August 2021 18:54 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/3 "2021-08-16T18:54:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![René](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ren%C3%A9/32/7_2.png) [@René](https://forum.robotframework.org/u/Ren%C3%A9)\
**Post date:** [16 August 2021 19:06 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/4 "2021-08-16T19:06:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rgraham5616](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rgraham5616](https://forum.robotframework.org/u/rgraham5616)\
**Post date:** [16 August 2021 19:40 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/5 "2021-08-16T19:40:31Z")

</div>

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

```python
${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.

---

<div class="post-metadata">

**Author:** ![rgraham5616](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rgraham5616](https://forum.robotframework.org/u/rgraham5616)\
**Post date:** [16 August 2021 19:41 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/6 "2021-08-16T19:41:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![René](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ren%C3%A9/32/7_2.png) [@René](https://forum.robotframework.org/u/Ren%C3%A9)\
**Post date:** [16 August 2021 20:01 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/7 "2021-08-16T20:01:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rgraham5616](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rgraham5616](https://forum.robotframework.org/u/rgraham5616)\
**Post date:** [16 August 2021 20:46 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/8 "2021-08-16T20:46:32Z")

</div>

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! 🙂

---

<div class="post-metadata">

**Author:** ![René](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ren%C3%A9/32/7_2.png) [@René](https://forum.robotframework.org/u/Ren%C3%A9)\
**Post date:** [16 August 2021 20:51 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/9 "2021-08-16T20:51:59Z")

</div>

you can try out version 1.3.0

`pip install robotframework-datadriver==1.3.0`

That should work as well

---

<div class="post-metadata">

**Author:** ![René](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ren%C3%A9/32/7_2.png) [@René](https://forum.robotframework.org/u/Ren%C3%A9)\
**Post date:** [16 August 2021 22:23 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/10 "2021-08-16T22:23:24Z")

</div>

@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?

> <https://github.com/Snooz82/robotframework-datadriver/issues/56>
>
> The current issue is that it is not clear what happens with tags of the template… test to all generated tests.
> 
> Options:
> \- The \`Tags\` of the template test could be added to all tests.
> \- No \`Tags\` of template is added to all tests.
> \- only \`Tags\` that are not used in the data source are added...
> 
> :-/

---

<div class="post-metadata">

**Author:** ![rgraham5616](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rgraham5616](https://forum.robotframework.org/u/rgraham5616)\
**Post date:** [17 August 2021 00:06 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/11 "2021-08-17T00:06:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Keyvan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/keyvan/32/1392_2.png) [@Keyvan](https://forum.robotframework.org/u/Keyvan)\
**Post date:** [2 April 2022 12:05 UTC](https://forum.robotframework.org/t/using-tags-declared-in-xls-datasheet/2278/12 "2022-04-02T12:05:45Z")

</div>

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
