I am trying to count the element with the code below
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;
Anyone can help me with this?
image.png
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:
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.
Sorry my bad. Upon re checking my xpath is wrong *[@VIEWS’]
Now is working and given me the output.
Thanks