Dear Support team,
I would like to know how can I count the number of list items (li) in a certain div.
(attached screenshot shows the html of the elements).
Get Number of total Option, doesn’t work since it requires a select field.
Dear Support team,
I would like to know how can I count the number of list items (li) in a certain div.
(attached screenshot shows the html of the elements).
Get Number of total Option, doesn’t work since it requires a select field.
Dear Support team,
I would like to know how can I count the number of list items (li) in a certain div.
(attached screenshot shows the html of the elements).
Get Number of total Option, doesn’t work since it requires a select field.
Hi there,
Please try the following solution where list.size() will be number of elements in this list
WebElement tem = driver.findElement(By.classname(“trip-cards”))
List list = temp.findElement(By.xpath(".//li"))
list.size()
Thanks
____________________
Thank you for choosing Katalon Studio as your automation solution.
Your feedback is needed to make Katalon Studio a better tool, take the survey at: https://goo.gl/S25NVO
This didn’t solve the problem. The driver.findElement is not Katalon syntax and when I tried
WebElement tem= WebUiCommonHelper.findWebElement(findTestObject(‘Object Repository/Page_Gazef/Page_Gazef/Trips/Search results/ul_trip-cards’), 20)
I got the same exception of:
[ERROR] - Test Cases/Trips/Search page (Compare top 2 labels) FAILED because (of) org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been “select” but was “ul”
Build info: version: ‘2.53.0’, revision: ‘35ae25b’, time: ‘2016-03-15 17:00:58’
System info: host: ‘Ayah-Nafie-Mac.local’, ip: ‘10.13.2.73’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.6’, java.version: ‘1.8.0_102’
Driver info: driver.version: unknown
Hi there,
Ah sorry my bad. You need to retrieve driver from DriverFactory class. My original script will look like this after adjustment
import org.openqa.selenium.By as By
import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.WebElement as WebElement
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
WebDriver driver = DriverFactory.getWebDriver()
WebElement temp = driver.findElement(By.className(‘trip-cards’))
List list = temp.findElement(By.xpath(’.//li’))
list.size()
Please use this instead.
Thanks
____________________
Thank you for choosing Katalon Studio as your automation solution.
Your feedback is needed to make Katalon Studio a better tool, take the survey at: https://goo.gl/S25NVO
It worked at last Thanks