最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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
发布评论

评论列表(0)

  1. 暂无评论