Search code examples
pycharmrobotframework

How do I access List Variables values in Robot Framework


How do I access particular value from List variable ? Instead It print entire List

*** Settings ***
Documentation    This Suite will have login test cases
#Library     SeleniumLibrary
Library     Selenium2Library
Resource   ../Resources/CommonFuntionality.robot
Variables   ../WebElements/Locators.py

*** Variables ***
@{userList}  standard_user  locked_out_user  problem_user  performance_glitch_user
${password}  secret_sauce
*** Keywords ***
Login With Valid User
    log to console  @{userList} [1]  **// This print entire list [standard_user  locked_out_user  problem_user  performance_glitch_user] instead I want locked_out_user to get print**
    input text  ${xUsername}  @{userList} [1]
    input text  ${xPassword}  ${password}
    click element  ${xLoginBtn}



Solution

  • Hope i help you

    *** Variables ***
    @{LIST}=          one    two    three
    
    *** Test Cases ***
    
    Print Value
        Log To Console      ${LIST[0]}
    

    Output :

    Print Value                                                           one
    Print Value                                                           | PASS |