Al Imran
Al Imran

Reputation: 882

How to use Variable and UserKeyword from test case level, which created at project level

How to use Variable and UserKeyword from test case level, which created at project level.

I have a robot framework project like:

Project
       Suite1
             TC_001
             TC_002
       Suite2
             TC_003
             TC_004

I have create Variable and UserKeyword at project level and I want to use those Variable and UserKeyword from test case level. My question is, how to use them at test case level?

Upvotes: 0

Views: 55

Answers (2)

A. Kootstra
A. Kootstra

Reputation: 6961

From the Robot Framework User Guide there are two sections you may want to go through in more detail:

Both of these describe how to import variables and external keywords from external files. In essence a resource file is a regular robot file but without the test cases. It only contains keywords and has the regular settings and variable sections. It can be imported in your test suite file through the Resource common.robot construct:

*** Settings ***
Resource          common.robot
Resource          feature_1.robot
Resource          feature_2.robot


*** Variables ***
${HOST}           localhost:7272

*** Keywords ***
Open Login Page
    Do something

Upvotes: 2

Todor Minakov
Todor Minakov

Reputation: 20067

You'll have to import the file created in the "Project" directory, and afterwards you'll have access to the variables and keywords defined in it.

If the file there is called "The_project_file.robot", in "Suite_1.robot":

*** Settings ***
Resource    ../The_project_file.robot

*** Test Case ***
TC_001
    Log    ${variable defined in The_project_file}
    ${value}=    Keyword Defined In The Project File

Upvotes: 2

Related Questions