You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You are correct the return type is always list of strings, even there is only one item in the list. I think it's better that keywords have only one return type, in this case a list. Because then one doesn't need write extra handling if user have a scenario where keyword can return zero or more elements.
#2514
Closed
4WvgqJu opened this issue
Jan 4, 2023
· 2 comments
You are correct the return type is always list of strings, even there is only one item in the list. I think it's better that keywords have only one return type, in this case a list. Because then one doesn't need write extra handling if user have a scenario where keyword can return zero or more elements.
Hard for me to understand what you write. Or are there no more issues? Maybe it is more understandable this way?
To my great surprise, the functions Get Count, Get Length from the library BuiltIn are not useful for counting the elements of the list. Because, the functions count either the number of characters of the element for one element in the container and the functions count the number of elements for more than one element in the container. Return value for ${attributes} = href is 4, return value for ${attributes} = ['href', 'onclick'] is 2. In other words, in the first case the function counts the characters of one element, in the other case the function counts the number of elements of the list.
It's a workaround using kind of reflection on types:
robotframework-browser issues 2513
[Documentation]
... https://https://github.com/MarketSquare/robotframework-browser/issues/2513
[Arguments] ${attributes} ${attribute}
FOR ${attribute} IN @{attributes}
Log ${attribute}
END
Test Insert
[Tags] AI INSERT
New Browser
Suppress Logging
Log ${this_is_whoever}
Log ${this_is_secret}
New Page ${url2}
Unsuppress Logging
Take Screenshot
${elements} = Get Elements ${elementHref}
FOR ${element} IN @{elements}
Log ${element}
${attributes}= Get Attribute Names ${element}
Log ${attributes}
${type}= Evaluate type($attributes)
Run Keyword If "${type}" == "<class${space}'list'>" robotframework-browser issues 2513 ${attributes} ${attribute}
${list}= Run Keyword If "${type}" == "<class${space}'str'>" Create List ${attributes}
Run Keyword If "${type}" == "<class${space}'str'>" robotframework-browser issues 2513 ${list} ${attribute}
END
Take Screenshot
Close Browser CURRENT
Originally posted by @aaltat in #2513 (comment)
The text was updated successfully, but these errors were encountered: