Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass command line arguments (test data parameters) in Robot framework

I want to run my test case with multiple test data (for different countries). Can this be achieved in the Robot framework? I have been working on RIDE IDE.

Below is sample code:

*** Settings ***
Suite Setup    Login to Application 
Suite TearDown    Logout and Close The Browser
Resource     import all required resource files 

***Test Cases ***
Sample Test Case To Create Data for Multiple countries 
     Select Country      USA       #here am hard coding the country value, instead I want to pass it in run time 
     Enter all required data 
     Click Submit

    #sample resource file that has the keyword for selecting Country Drop down and fill other details
    *** Keywords ***
    Select Country
    [Arguments]       ${value} 
    Select From List By Label    ${locator}    ${value}
    Input Text      locator    text value 

I tried to pass the arguments in test case but it says sanity check fails. Reset changes in the RIDE IDE the moment I add arguments at the Test case level.

I am using Python 2.7.14, RIDE 2.0a1.

like image 668
Sailesh Botcha Avatar asked Jul 19 '18 04:07

Sailesh Botcha


People also ask

How do you pass a dictionary argument in Robot Framework?

To pass a dictionary to a keyword, you do it like any other argument. In your case, if you have a dictionary named ${Participants} , you would pass it as ${Participants} . As for iterating over the dictionary, you need to replace $ with @ , and use FOR/IN.

How do I run a command in Robot Framework?

You can add any number of commands using 'Execute Command' keyword in script and run. Below am listing few of SSHLibrary Keywords in Robot framework and their usage: Open connection - Opens connection to Remote machine. Close Connection - Closes the existing active remote connection.


1 Answers

In the Robot Framework Userguide there is an entire chapter on Configuring the Execution of Robot Framework. In this chapter there is a section on passing variables via the command line.

An example:

robot --variable OS:Linux --variable IP:10.0.0.42 my_test_suite_file.robot

and then you can use the variables ${OS} and ${IP} at any point in your scripts as they are Global variables.

like image 89
A. Kootstra Avatar answered Sep 30 '22 09:09

A. Kootstra