I found out, that there are Get Text and Get Value keywords, to obtain the string from defined element. However, these keywords will work only if you know for sure, that the element in provided locator have string in Text or Value attribute.
I want to create a locator, which returns multiple elements, where some of them may have string stored in Text and some of them in Value. Is there a keyword, function or different trick, how to get the string from an element, regardless of its type?
I tried to use Evaluate with a piece of JavaScript I found somewhere, but it gives me some syntax error, which Iām unable to fix. I just donā't see an obvious error? But I guess it will not provide me with the result I want anyway.
An idea, would be to build a keyword that check whether one or the other (text or value) exists, then depending of this get the other.
I see in your screen that the ${login.button} has no text but a value, so something like this :
Get_Element_Content
[Arguments] ${myelement}
${hasValue} Run Keyword and Return Status Get Element Attribute ${myelement} value
IF ${hasValue} == ${True}
${content} Get Element Attribute ${myelement} value
ELSE
${content} Get Text ${myelement}
END
RETURN ${content}
Thank you for the suggestion. Itās almost exactly what I thought about, as a ālast resortā solution I just hoped for something more straightforward and one-method/line solution. But it seems I will have to live with your solution. Thank you!