# Count Element help

**URL:** <https://forum.katalon.com/t/count-element-help/14001>\
**Category:** Miscellaneous\
**Created:** [October 30, 2018, 1:41am UTC](https://forum.katalon.com/t/count-element-help/14001 "2018-10-30T01:41:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohd\_Shahrul\_Iman](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mohd_shahrul_iman/32/23870_2.png) [@Mohd\_Shahrul\_Iman](https://forum.katalon.com/u/Mohd_Shahrul_Iman)\
**Post date:** [October 30, 2018, 1:41am UTC](https://forum.katalon.com/t/count-element-help/14001/1 "2018-10-30T01:41:26Z")

</div>

I am trying to count the element with the code below

```auto
WebDriver driver = DriverFactory.getWebDriver()List<WebElement> eleCount = driver.findElements(By.xpath("//*[@id='SUB-VIEWS']/div[2]/div/div[2]/form/div/div[3]/div[2]/div/div[1]/div/div/div/div[2]/div/div/div[9]/div/div/div/div/div[2]/div/ul/li"))int rowsInTable = eleCount.size()println(rowsInTable)

```

However, I am getting this error

> [FAILED] - Unable to get total options of object ‘Object Repository/Create Person/CountrySearchResult\_dropdown’ (Root cause: org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been “select” but was “li”

I am trying to test to print out the total count element.  
Below is the example page;

```auto

```

Anyone can help me with this?

[image.png](https://s3.amazonaws.com/katalon-forum/editor/gq/1rwm1vfb8wyb.png)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 30, 2018, 2:09am UTC](https://forum.katalon.com/t/count-element-help/14001/2 "2018-10-30T02:09:04Z")

</div>

I am confused.

> [FAILED] - Unable to get total options of object ‘Object Repository/Create Person/CountrySearchResult\_dropdown’ (Root cause: org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been “select” but was “li”

This message indicates that you have a TestObject named ‘Object Repository/Create Person/CountrySearchResult\_dropdown’ and it is causing failure.

On the other hand you showed us code snippet:

```auto
WebDriver driver = DriverFactory.getWebDriver()List<WebElement> eleCount = driver.findElements(By.xpath( "//*[@VIEWS']/div[2]/div/div[2]/form/div/div[3]/div[2]/div/div[1]/div/div/div/div[2]/div/div/div[9]/div/div/div/div/div[2]/div/ul/li"))int rowsInTable = eleCount.size()println(rowsInTable)

```

This code snippet does not use the above-mentioned TestObject at all. This code section seems to have nothing to do with the failure.

You should read the message carefully and find out where the problem resides actually.

---

<div class="post-metadata">

**Author:** ![Mohd\_Shahrul\_Iman](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mohd_shahrul_iman/32/23870_2.png) [@Mohd\_Shahrul\_Iman](https://forum.katalon.com/u/Mohd_Shahrul_Iman)\
**Post date:** [October 30, 2018, 2:24am UTC](https://forum.katalon.com/t/count-element-help/14001/3 "2018-10-30T02:24:53Z")

</div>

Sorry my bad. Upon re checking my xpath is wrong \*[[@VIEWS’]](http://forum.katalon.com/profile//VIEWS%27%5D%2Fdiv%5B2%5D%2Fdiv%2Fdiv%5B2%5D%2Fform%2Fdiv%2Fdiv%5B3%5D%2Fdiv%5B2%5D%2Fdiv%2Fdiv%5B1%5D%2Fdiv%2Fdiv%2Fdiv%2Fdiv%5B2%5D%2Fdiv%2Fdiv%2Fdiv%5B9%5D%2Fdiv%2Fdiv%2Fdiv%2Fdiv%2Fdiv%5B2%5D%2Fdiv%2Ful%2Fli%22%29%29)

Now is working and given me the output.

Thanks
