How to put a variable value with semicolons and forwardslashes inside a list and get read by it

Viewed 19

Here's my list

@{referentiel}      N1(exemple)/N2(exemple)     N2(exemple)/exemple

where i use it

Visca barca
    [Arguments]                      ${index}   
    Click Element Using Javascript   //div[@id='mat-select-value-5']
    Click element of long page       //span[@class='mat-option-text'][contains(.,'@{referentiel}[${index}]')]

And my testcase

we are the best

    Visca barca                              1         

Error :

Value of variable '@{referentiel}[${index}]' is not list or list-like.

1 Answers

The issue you are describing here has nothing to do with the semicolons or slashes. The issue is actually that you are attempting to return the list item with wrong decorator.

To get a single item from a list you should use $ instead of @. When you use @ Robot will attempt to return you a list which it cannot since the item on ${index} is a string. See below:

@{referentiel}  # == ['N1(exemple)/N2(exemple)', 'N2(exemple)/exemple']

or

${referentiel[0]}  # == N1(exemple)/N2(exemple)
Related