Hello,
I have a problem with a piece of code and I need help
Here is my code :
${elements}= Get WebElements //div[1]/inotr-bloc-annonce
FOR ${element} IN @{elements}
Log ${element}
Element Attribute Value Should Be ${element} data-transaction VENTE
END
My goal is to verify that âdata-transactionâ attribute can have either âVENTEâ value or âXXâ value or âYYâ value.
I try to insert a âORâ condition inside de âFORâ loop but it doesnât work.
Thanks for your help !
Hi John,
How about this approach using List Should Contain Value:
@{ValidDataTransactions}= Create List VENTE XX YY
${DataTransaction}= Get Element Attribute ${element} data-transaction
List Should Contain Value @{ValidDataTransactions} ${DataTransaction}
Dave.
Hi Dave,
Thanks for your answer.
Do you mean an approach like this :
@{ValidDataTransactions}= Create List VENTE XX YY
${elements}= Get WebElements //div[1]/inotr-bloc-annonce
FOR ${element} IN @{elements}
Log ${element}
${DataTransaction}= Get Element Attribute ${element} data-transaction
List Should Contain Value @{ValidDataTransactions} ${DataTransaction}
END
I try it but I have an error (Keyword âCollections.List Should Contain Valueâ expected 2 to 3 arguments, got 4.). Perhaps I have a bad construction of my code ?
Hi John,
Yeah thatâs the idea, try changing the @ to a $ on the List Should Contain Value
line:
List Should Contain Value ${ValidDataTransactions} ${DataTransaction}
Sometimes RF wants it one way and sometimes the other, iâm never really quite sure, I just try it and if I get an error I try the other way, same thing with dictionaries (swap & and $).
Dave.
1 Like
Youâre alright. Iâve already seen this kind of âproblemâ but I forgotâŚ
Indeed, the result is now correct
Thanks a lot !
A last question : do you know why I have a warning near the âList Should Contain Valueâ line saying : Keyword âList Should Contain Valueâ is from a library nested a resource file ?
Hi John,
List Should Contain Value
comes from the Collections Library, you should include:
*** Settings ***
Library Collections
in your robot file, it must be in another robot file that you included in this robot file so thatâs how itâs picking it up, but giving you a warning because itâs not in this robot file.
when ever you use a keyword that is not from the builtin library, you should add that library to your robot file.
Dave.
Ok, I thought that when I use Standard Librairies, Itâs useless to put it on âSettingsâ section.
Thanks to you, I know that itâs usefull only for keywords which are not in âBuiltInâ library !
Thanks again