# Unable to get text in a list

**URL:** <https://forum.katalon.com/t/unable-to-get-text-in-a-list/60529>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [December 2, 2021, 4:12pm UTC](https://forum.katalon.com/t/unable-to-get-text-in-a-list/60529 "2021-12-02T16:12:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![julia.poirier-boulan](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/julia.poirier-boulan/32/16104_2.png) [@julia.poirier-boulan](https://forum.katalon.com/u/julia.poirier-boulan)\
**Post date:** [December 2, 2021, 4:12pm UTC](https://forum.katalon.com/t/unable-to-get-text-in-a-list/60529/1 "2021-12-02T16:12:04Z")

</div>

Hi! I try to get the text from the elements of a list without success. This is the html source code from the webpage:

> **View the full list of Sign-In Partners**
>
> - Affinity Credit Union
> - Alberta Treasury Branches
> - BMO Financial Group
> ...
> 
> And this is my attempt to get the text from it:  
> WebDriver driver = DriverFactory.getWebDriver()  
> List list = driver.findElements(By.xpath("/html/body/main/div[2]/div/div[1]/div[3]/div/div/details/ul/li"))  
> for (element in list)  
> {  
> System.out.println(element.getText())  
> }
> 
> This code results in 16 empty strings in the console since there are 16 elements in the list.  
> Thank you for your help!

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [December 2, 2021, 6:50pm UTC](https://forum.katalon.com/t/unable-to-get-text-in-a-list/60529/2 "2021-12-02T18:50:07Z")

</div>

To get the HTML source code on Chrome, **right** click by your element and select “Inspect” (do this twice). If we get to see the actual HTML, then we may be able to assist better.

While reviewing your HTML pathway, is there any static **id** or **name** tag closer to the end of your xpath `//details/ul/li`. You currently have such a long pathway that it is likely to get broken.

To display your code properly, put three back ticks (found on the same key as the tilde) above and below, like ```

```auto
WebDriver driver = DriverFactory.getWebDriver()
List<WebElement> list = driver.findElements(By.xpath("//html/body/main/div[2]/div/div[1]/div[3]/div/div/details/ul/li"))
for (element in list)
{
    System.out.println(element.getText())
}

```
