Data driven testing using excel

How to read multiple excel sheets in one robot file.
For example there are three sheets in a excel.
How do I mention in settings
There are three keywords.
First key word will use first excel sheet data,second use second excel sheet data, third use third excel sheet data.
How do I call keywords in testcase section. If all keywords have same number of arguments

Hi Mahesh,

I believe you can only specify 1 sheet when you import data driver → XLS / XLSX Files

I’d suggest you break it into 3 robot files, 1st robot file imports sheet 1 and calls keyword 1, etc.

Put the 3 files in a directory with the name of your current robot file and then when you run robot give it this directory instead of a robot file, robot will run all the robot files in this directory and still give you 1 log result.

Hope that helps,

Dave.

I have one more dobut
If we are testing a complex website which contain more screens. How do we maintain the project structure
. Have to kept keywords in one robot file, variables in robot file, test scenarios in one file.

Hi Mahesh,

Yes keep all your common keywords and variables in a robot file that has no test cases, then just include it in your robot files that do have test cases, you can see Resource files for details.

Depending on how complex your app is you might want to have multiple robot resource files of keywords grouped by business area or user type, however you want to structure it.

For example: for one app I had

  • appname.robot, this file didn’t have any keywords, variables or test cases, just references to all my resource files (below)
    • appmain.robot, this file had the main url in variables, and keyword for login, logout and top level menu navigation
    • ModuleA.robot, this had all the keywords related to Module A (e.g. this might be your HR module, so keywords relating to submitting timesheets, leave requests etc)
    • ModuleB.robot, pretty sure you can guess

Then in my test case robot files I just add a a reference to appname.robot and all the keywords from the other robot files become available to my test cases.

You can see an example of this here: Create common robot file for generic actions in robot framework - #2 by damies13

You can organise it however you like, but that’s what made sense for me when dealing with a large complex application.

Dave.

1 Like

Thanks
Suppose if there are 10 test cases in a robot file.
If i run with file name all case are executing. If i want to run specific cases I am commenting the remaining cases and executing the rest of the cases.
Is there anyway to execute the particular case with out commenting the rest of the cases.

To find text color or whether it is bold or normal text
I am using execute javascript return window. Computedstyle(js_path). Color Or. Fontweight

Is there any easy way to this

Hi Mahesh,

There’s no need to comment out test cases, if you run robot -h you’ll get the full command line help for robot, in there you’ll see:

-t --test name *         Select tests by name or by long name containing also
                          parent suite name like `Parent.Test`. Name is case
                          and space insensitive and it can also be a simple
                          pattern where `*` matches anything, `?` matches any
                          single character, and `[chars]` matches one character
                          in brackets.

and

 -i --include tag *       Select tests by tag. Similarly as name with --test,
                          tag is case and space insensitive and it is possible
                          to use patterns with `*`, `?` and `[]` as wildcards.
                          Tags and patterns can also be combined together with
                          `AND`, `OR`, and `NOT` operators.
                          Examples: --include foo --include bar*
                                    --include fooANDbar*
 -e --exclude tag *       Select test cases not to run by tag. These tests are
                          not run even if included with --include. Tags are
                          matched using same rules as with --include.

so with -t you can specify just the 1 test case (or just a couple of test cases) you want to run, but if you have tags on your test cases you can also do useful things like only running test for a specific tag or running all test excepts ones with a specific tag

You can also do useful things like overwriting variable values, it’s really worth reading so you know what’s there.

Dave.

1 Like