Handling List in div Tag


Hello,

I have a list under the highlighted div tag. when i search for a particular item in the list and try to get the text, its giving null output. Katalon is new to me, can you please help me.
My code:
WebUI.setText(findTestObject(‘Remedi Web Repo/Nurse Dashboard/FixAppointment/fixAppointmnetWindow/input_DoctorName’), searchString)

if(WebUI.verifyTextPresent(‘No records found’, false, FailureHandling.OPTIONAL)==true)
{
println(‘No Records Found’)
} else {
for (int i = 0; i < count; i++) {
String doctorDetails = doctorsList.get(i).getText()

    println(doctorDetails)

    String doctorName = doctorDetails.split('\n')[0]

    println(doctorName)

    if (doctorName.contains(searchString)) {
        doctorsList.get(i).click()
		break
    }
	break
}

}

You will have to finish off the xpath that is “hidden” lower than the div with the “selectDoctor” class, but you can have something like below.

This creates a list of webelements from which you can get the text.

WebDriver driver = DriverFactory.getWebDriver()

List<WebElement> doctorList = driver.findElements(By.xpath('id("doctorSearchResult")/div/**whatever is below**'));

dr_count = doctorList.size();

for (int i = 0; i < dr_count; i++) {

or you can go for several individual web elements, with pathway like:
id("doctorSearchResult")/div[1]/**whatever is below**
id("doctorSearchResult")/div[2]/**whatever is below**
id("doctorSearchResult")/div[3]/**whatever is below**
id("doctorSearchResult")/div[4]/**whatever is below**
id("doctorSearchResult")/div[5]/**whatever is below**

1 Like