Search code examples
automationrobotframeworkrpa

Should contain atleast using Robotframework


Created a list where in @{test} XTEAMK01, KKTEAM01, XTEAMO01, KKTEAM02, XJSTEAMD00, KKTEAM03 and then I want to get the following values that start with "KK" KKTEAM01, KKTEAM02,KKTEAM03


Solution

  • Using @WindCheck you can format the code to work in robot. This code will produce the result you want.

    ***Variables***
    @{test}     XTEAMK01    KKTEAM01    XTEAMO01    KKTEAM02    XJSTEAMD00    KKTEAM03  
    *** Test Cases ***   
    Example                
        ${x}=    Evaluate    [item for item in ${test} if item.startswith("KK")]
        Log    ${x}
    

    alternatively you can use the other answers as well.