gurpreetsingh
gurpreetsingh

Reputation: 1

How to make Robot Framework Data Driven?

In a test case I am able to read a csv file by following code

${value} =   read_csv_file    TestData.csv
   Set Test Variable    ${value}
   log   ${value}

But now the question comes why my test case will repeat for different data. Although if I want to repeat any step I can use for loop but I want to repeat this for entire test suite.

:FOR  ${newvalue}   in   @{value}
  \       Select Product   @{newvalue}[0]

Templates are not preferred because they make the framework totally data-driven and also they have certain limitation.

Upvotes: 0

Views: 987

Answers (1)

Keerty Verma
Keerty Verma

Reputation: 21

As you don't want to use templates, you can also use keyword-driven approach of robot framework. You need to create a robot resource file, define your keyword and call it where you want this particular code in your robot test suite.

***keywords***
Read and display
    [Argument]    ${filename}
    ${value} =   read_csv_file    ${filename}
    Set Test Variable    ${value}
    log   ${value}

Upvotes: 1

Related Questions