最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

python - IF element IN list in robot framework - Stack Overflow

matteradmin6PV0评论

I am trying to see if the element is present in the list using Robot Framework. This is my test:

IF   Calgary    IN   ${list}
     do something
END

But I am getting this error No keyword with name 'IN' found

I am trying to see if the element is present in the list using Robot Framework. This is my test:

IF   Calgary    IN   ${list}
     do something
END

But I am getting this error No keyword with name 'IN' found

Share Improve this question edited Jan 23 at 11:31 Mohsen Khosroanjam 5831 gold badge3 silver badges20 bronze badges asked Nov 18, 2024 at 18:21 Urvish ranaUrvish rana 64810 silver badges24 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

it uses Python 'in' so it should be like this

IF classic in ${list}

You can also do this by using List Should Contain Value built-in function. This built-in function checks whether the value exists in the given list and if it fails, it shows the msg(if you do not pass msg, it shows a default error).

List Should Contain Value    list_    value

Example:

*** Settings ***
Library    Collections
*** Variables ***
@{list}    Toronto    Vancouver    Calgary

*** Test Cases ***
check
    List Should Contain Value   ${list}    Calgary    msg=The item not found
Post a comment

comment list (0)

  1. No comments so far