dotnet Learner
dotnet Learner

Reputation: 9

how to get variable in testcase pass from Command line argument in Robot framework

in below Example, I want to get url from Command prompt

*** Settings ***
Library  SeleniumLibrary

*** Variables ***

*** Test Cases ***
TestModule
    Launch webpage

*** Keywords ***
Launch webpage
    Open Browser    $[url]  chrome
    Wait Until Page Contains  Amazon.in
    Close Browser

Upvotes: 0

Views: 1199

Answers (1)

yogev
yogev

Reputation: 214

the way to use robotframework cmd variables is the following: robot --variable EXAMPLE:value path/to/test

so in your case:

robot --variable url:<url_value> path/to/test

your code should look like this:

*** Settings ***
Library  SeleniumLibrary

*** Variables ***

*** Test Cases ***
TestModule
    Launch webpage

*** Keywords ***
Launch webpage
    Open Browser    ${url}  chrome
    Wait Until Page Contains  Amazon.in
    Close Browser

Upvotes: 2

Related Questions