How to execute test suite for multiple roles and groups

Hi, I’m a beginner; created a test suite that I want to execute for multiple roles; and based on the role, locators change, how can I achieve this?
current test project setup is as follows:
Test Project

  • Resources–>PO
    –>Common
    -Tests–>Group1–>Role1
    –>Role2
    –>Group2–>Role1
    –>Role2

Using a csv/excel/json allows me to execute each TC for every role, but I want to execute the entire test suite for one role at a time

Hi @smaheedhara,

Maybe this is something you are looking for: GitHub - Snooz82/robotframework-datadriver: Library to provide Data-Driven testing with CSV tables to Robot Framework. According to the documentation:

DataDriver uses the Listener Interface Version 3 to manipulate the test cases and creates new test cases based on a Data-File that contains the data for Data-Driven Testing. These data file may be .csv , .xls or .xlsx files.

Here is the usage example: GitHub - Snooz82/robotframework-datadriver: Library to provide Data-Driven testing with CSV tables to Robot Framework

Hope this helps.

2 Likes

Here is a working example.

  • If you set the folders & files up as below, you should be able to run this & change the ${ROLE} variable from standard to administrator & see the output change.
  • You could consider housing the variable in a passed-in command-line variable to the robot call, or in a *.toml file profile etc. (changeable for the whole project from 1 place)
  • This uses the DataDriver library. Please ensure to run pip install --upgrade robotframework-datadriver & see here for more info on that: robotframework-datadriver · PyPI

test/data_driven_test_case.robot file:
*** Variables ***
${ROLE} standard *** Settings ***
Library DataDriver ../test_data/test_data_${ROLE}_role.csv
Test Template Log data found in data file *** Test Cases ***
Login with user ${username} and password ${password} DefaultUsername DefaultPassword *** Keywords ***
Log data found in data file
[Arguments] ${username} ${password}
Log "DATA FOUND: username '" ${username} "'' & password '" ${password} "'"

test_data/test_data_administrator_role.csv:
${username};${password}
administrator_role_username;administrator_role_password

test_data/test_data_standard_role.csv:
${username};${password}
standard_role_username1;standard_role_password1
standard_role_username2;standard_role_password2 (edited)