I have some web elements which has the same prefix for their ID
attribute. I can get these elements all at once with get webelements
; I want to extract their text attribute with one command. I have wrote this line:
${elList} = get webelements xpath=//*[starts-with(@id, '${formName}:${row}')]
${rowList} = evaluate [item.get_attribute('text') for item in ${elList}] selenium
Which returns:
Evaluating expression '[item.get_attribute('text') for item in [<selenium.webdriver.remote.webelement.WebElement object at 0x7f7b6c5f09d0>, <selenium.webdriver.remote.webelement.WebElement object at 0x7f7b6c5f0990>]]' failed: SyntaxError: invalid syntax (<string>, line 1)
I can't understand the problem here; BTW I'll appreciate any other solution for my issue.
EDIT1: I also have tried below code:
${elList} = get webelements xpath=//*[starts-with(@id, '${formName}:${row}')]
:FOR ${item} IN @{elList}
\ log to console ${item.get_attribute('text')}
But the console just shows None
; it is the same for ${item.get_attribute('value')}
.
I've solved this; I found this answer and used ${item.get_attribute('innerHTML')}
as a try. It worked pretty fine.