Incomplete values of rows column number 4 (handling web tables)

Hi, I want to count all the rows in the table but the results are incomplete
kindly check my codes:

'To locate rows of table it will Capture all the rows available in the table'
List<WebElement> rows_table = Table.findElements(By.tagName('tr'))

'To calculate no of rows In table'
int rows_count = rows_table.size()

Double due = 0
Double withdraw = 0
String numtext = ""
String rowtext = ""

'Loop will execute for all the rows of the table'
Loop: for (int row = 0; row < rows_count;row++) {
    'To locate columns(cells) of that specific row'
    List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName('td'))

    'To calculate no of columns(cells) In that specific row'
    int columns_count = Columns_row.size()

    println((('Number of cells In Row ' + row) + ' are ') + columns_count)

    //Double withdraw=row
    //String total =due-withdraw
    'Loop will execute till the last cell of that specific row'
	
	String celltext = Columns_row.get(4).getText()
	println("Celltext "+celltext)
	if ((celltext != '-') && (celltext.equals('') == false)) {
		due = (due + Double.parseDouble(celltext.replace(',', '')))
		numtext = numtext +"|"+ celltext;
		rowtext = rowtext + "|"+row;
	   // println(('celltext' + celltext) + ' test')

		println('running due: ' + due)
		
	}
	
	//println(numtext)

    String totalnetcash =  due

    //println('total netcash:' + totalnetcash)

    WebUI.setText(findTestObject('Single Payment/Page_Core/Netcash'), totalnetcash)
	
}
println(numtext)
println(rowtext)

The result is they skip the 1-7 rows.

are you sure tht there ara data on those rows?
take rowtext operation outside if and run again…

yes sir , check on the screenshot that I printed (numtext) above the highlights.

but you fill/change that variable inside of condition…
change code like this:

rowtext = rowtext + "|"+row;
if ((celltext != '-') && (celltext.equals('') == false)) {
	due = (due + Double.parseDouble(celltext.replace(',', '')))
  // rowtext = rowtext + "|"+row;
	numtext = numtext +"|"+ celltext;
   // println(('celltext' + celltext) + ' test')
	println('running due: ' + due)
	
}

btw nutext will not show what is on what row since it’s again in condition for leave empty rows.
to really check what is where i’ll put folowing before that if:

println "row: ${row};       cell data: ${celltext};"

Count of rows are complete but the data in the row 1-7 are not printed.

that was reason you did not see rows in your output
or did i miss reason for your question?

Ahm. I think thats an another error I encountered , when getting the value in the row 1-7 is blank. What is the possible reason that the value in row 1-7 are not fetching while the other rows are fetched.

hello what do you mean by this? the data are fetching but incomplete, thanks.

could you please post html snipplet of that table? rowd 0 to 15

please see attached file, thanks.

can you post it as text? picture will not allow me to take it and run test by myself (i dont want to recreate that html by hand by myself)

please see attaached textfile:
textfile.txt (31.7 KB)

1 Like