# Help looping and comparing lists

**URL:** <https://forum.robotframework.org/t/help-looping-and-comparing-lists/5732>\
**Category:** SeleniumLibrary\
**Created:** [23 May 2023 07:22 UTC](https://forum.robotframework.org/t/help-looping-and-comparing-lists/5732 "2023-05-23T07:22:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![resourceful-idiot](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@resourceful-idiot](https://forum.robotframework.org/u/resourceful-idiot)\
**Post date:** [23 May 2023 07:22 UTC](https://forum.robotframework.org/t/help-looping-and-comparing-lists/5732/1 "2023-05-23T07:22:53Z")

</div>

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}

```

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [23 May 2023 09:39 UTC](https://forum.robotframework.org/t/help-looping-and-comparing-lists/5732/2 "2023-05-23T09:39:45Z")

</div>

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.

```python
| ***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}"]} |

```

---

<div class="post-metadata">

**Author:** ![resourceful-idiot](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@resourceful-idiot](https://forum.robotframework.org/u/resourceful-idiot)\
**Post date:** [23 May 2023 18:31 UTC](https://forum.robotframework.org/t/help-looping-and-comparing-lists/5732/3 "2023-05-23T18:31:04Z")

</div>

Thank you very much. This is very helpful I am using it now and will see if it works.
