How can i get datas from rows

Hi guys i am having problem with get the datas in rows. i want the get the datas from under Name Surname column

import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import org.openqa.selenium.By
import org.openqa.selenium.WebElement
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

WebUI.callTestCase(findTestCase('Login Page/Login'), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.verifyElementPresent(findTestObject('Object Repository/Home Page/patientListTable'), 5)
WebUI.verifyElementPresent(findTestObject('Object Repository/Home Page/patientList_Row'), 5)

List<WebElement> rows = WebUI.findWebElements(findTestObject('Object Repository/Home Page/patientList_Row'),5)
assert rows.size() > 1
int numberOfRows = rows.size()
println "numberOfRows=${numberOfRows}"

for (WebElement row in rows) {
	WebElement name = row.findElement(By.xpath("//div[@data-field='nameSurname']"))
	assert name != null
	println "name=${name.getText()}"
}

this is my code and this is the html code sorry for the censor. the xpath in devs console is for the rows and it is correct.


when i execute the code above it only prints NAME SURNAME in the console.
image

its fixed guys this is the solution if anyone needs it

List<WebElement> rows = WebUI.findWebElements(findTestObject('Object Repository/Home Page/patientList_Row'), 10)

int rowIndex = 1 // Counter variable for row index

// Loop through the rows to extract patient names and surnames
for (int i = 1; i < rows.size(); i++) {
	// Get the current row
	WebElement row = rows.get(i)
	WebElement firstCell = row.findElement(By.xpath(".//div[@data-field='nameSurname']"))
	String columnName = firstCell.getText()

	// Split the column name into patientName and patientSur using space as delimiter
	String[] nameParts = columnName.trim().split("\\s+")
	String patientName = nameParts[0]
	String patientSur = nameParts[1]

	// Print the extracted data to the console
	println("Row $i: patientName=$patientName, patientSur=$patientSur")
2 Likes