'AttributeError: 'list' object has no attribute 'lower'
I get above error for following 2 scripts, what could be reason.
*** Settings ***
Resource resource.txt
*** Variables ***
@{ExpectedCookieValue} selenium1234
@{ExtractedCookieValue} ${Empty}
*** Test Cases ***
CookieTest
Open Browser http://www.google.com ${Browser}
Maximise Browser Window
Add Cookie SeleniumTest selenium1234
Get Cookie Value SeleniumTest
${ExtractedCookieValue} Get Cookie Value SeleniumTest
Log "Extracted Cookie Value"
Log ${ExtractedCookieValue}
Should Be Equal ${ExtractedCookieValue} ${ExpectedCookieValue} 'Cookie Should Be Equal'
Close Browser
2nd Script
*** Settings ***
Resource resource.txt
*** Test Cases ***
AlertTest
Open Browser http://www.seleniummaster.com/robotframeworktest/alerttest.html ${Browser}
Sleep 5s
Click Button name=alert_button
Sleep 5s
Alert Should Be Present This is an alert box
Close Browser
Solution 1:[1]
I had defined a List Variable instead of Scalar. Went to resource file and defined Scalar Variable ${Browser} Firefox and Removed the following List Variable @{Browser} Firefox
Solution 2:[2]
Context: Robot Framework 4.1 (Python 3.9.6 on win32)
Similar to what Maq Said noted re "list vs scalar" - I had same error while iterating in a FOR loop through a list which I had defined using ${listname}. When I changed notation to @{listname} ($ to @) I got no error, and contents were listed. Code below, super simple, I hope this note helps someone:
FOR ${each_item} IN @{element_attribute_list} #list of href URLs
log to console "element ===>" ${each_item}
END
OUTPUT:
"element ===>" https://www.example.org/terms-of-use
"element ===>" https://www.example.org/contact_us
"element ===>" https://www.example.org/group-sales
... etc ...
Also to help with clarity here is cross-reference post and excerpt from Stackoverflow, another instance: In Robot Framework, what is the difference between a List Variable and a Scalar Variable containing a list?
| @{list} = | Create List | a | b | c |
| ${scalar} = | Create List | a | b | c |
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Maq Said |
| Solution 2 | Dave Parham |
