admin管理员组

文章数量:1023857

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

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

本文标签: pythonIF element IN list in robot frameworkStack Overflow