How can I get All Text in robot framework ?

+1 vote

I have written this following source code,

<div id="groupContainer" class="abcdef">

<ul id="GroupContactListWrapper" class="list-wrapper">
    <li class="contactNameItemContainer">

        <div class="contactNameItem">
            <span class="name">Name</span>
        </div>

    </li>
    <li class="contactNameItemContainer">

        <div class="contactNameItem">
            <span class="name">Name1</span>
        </div>

    </li>
</ul>

</div>

How can I retrieve the names (Name, Name1) in a list variable? I tried using the XPath to "Get Text" keyword but only returns the first one.

//div[@id='groupContainer']//li[@class='contactNameItemContainer']//span

Please help me with a suitable answer.

Jul 1, 2019 in Selenium by Vaishnavi
• 1,180 points
1,021 views

1 answer to this question.

+1 vote
${elem} =   Get WebElements      xpath://div[@id='groupContainer']//li[@class='contactNameItemContainer']//span

FOR  ${item}  IN  @{elem}
   log to console  Item: ${item.text}

END
answered Jan 29 by Abhishek
• 160 points

Related Questions In Selenium

0 votes
1 answer

How can I clear the text in a text box using Selenium WebDriver?

Hello Akriti, you can clear the text ...READ MORE

answered May 29, 2019 in Selenium by Anvi
• 14,010 points
661 views
0 votes
1 answer
0 votes
1 answer

How can I get Webdriver Session ID in Selenium?

Hey Nargis, you can use following methods ...READ MORE

answered Jun 21, 2019 in Selenium by Abha
• 27,800 points
2,926 views
0 votes
1 answer
+2 votes
2 answers

How can I press ENTER key with the execute_script in selenium python?

The below code containing Keys.ENTER might just ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,510 points
11,927 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
2,170 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,870 points
1,800 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,870 points
1,766 views