Hi,
I am trying to check all the text values at a given class match those in original list but I’m a bit confused. I’ve looped through all the texts, put them in @{list1} but when I try to compare with @{original-list} it’s not working wit the error: No keyword with name ‘BLAH1’ found.
Verify System Names
@{original-system-header-text} BLAH1 BLAH2 BLAH3 BLAH4
@{system-header-text}= Get WebElements //*[@class="system-header-text"]
FOR ${element} IN @{system-header-text}
${temp-list}= Get Text ${element}
END
Lists Should Be Equal @{original-system-header-text} ${temp-list}
Well, your problem is not directly related to SeleniumLibrary, but to variable handling in general.
Direct assigning is not possible (yet), so BLAH1 is the name of a called keyword.
There are other problems in using list variables. I have prepared a runable test for you to see the differences.
| *** Settings *** |
| Library | Collections |
| *** Variables *** |
| &{MEMORY} | elem1=BLAH1 | elem2=BLAH2 | elem3=BLAH3 | elem4=BLAH2 |
| *** Test Cases *** |
| Verify System Names |
| | @{original-system-header-text}= | Create List | BLAH1 | BLAH2 | BLAH3 | BLAH4 |
| | @{system-header-text}= | Get WebElements | //*[@class="system-header-text"] |
| | ${temp-list}= | Create List |
| | FOR | ${element} | IN | @{system-header-text} |
| | | ${temp}= | Get Text | ${element} |
| | | Append To List | ${temp-list} | ${temp} |
| | END |
| | Lists Should Be Equal | ${original-system-header-text} | ${temp-list} |
| *** Keywords *** |
| Get WebElements |
| | [Arguments] | ${arg} |
| | @{values}= | Create List | elem1 | elem2 | elem3 | elem4 |
| | RETURN | ${values} |
| Get Text |
| | [Arguments] | ${element} |
| | RETURN | ${MEMORY["${element}"]} |
2 Likes
Thank you very much. This is very helpful I am using it now and will see if it works.
1 Like