Get Text from Cell on Table

I can’t get text from cell on table.
I’ve use getText() and getAttribute(‘value’)

example:
String celltext = Columns_row.get(column).getAttribute(‘value’)
or
String celltext = Columns_row.get(column).getText()

but, still return ‘null’

ok,
1. i guess you are using something similar to : https://medium.com/@katalon_studio/how-to-handle-web-tables-866c7c82d615
2. do you have any errors?
3. post HTML of table you want process (or a snipplet of that table) so we can see structure

I’ve use this code.
but this code return ‘’

2018-08-10_11-04-19.png

2018-08-10_11-00-12.png

what is result of:

println Columns_row.size()

since i dont see all script you are using, it’s hard to tell what’s wrong

it seems that definition by which you want to get rows/columns does not return what you need

I don't see this script helping

2018-08-10_13-30-16.png

This is code program.
return number and column is Valid.
but when getText, return ''

WebDriver driver = DriverFactory.getWebDriver()

String ExpectedValue = ‘11/30/2017’

int count = 0

WebElement Table = driver.findElement(By.xpath(’//*[@id=“dgPaymentScheduleDetail”]/div/div[6]’))

List rows_table = Table.findElements(By.tagName(‘tr’))

int rows_count = rows_table.size()

WebUI.verifyEqual(rows_count, 13, FailureHandling.STOP_ON_FAILURE)

Loop: for (int row = 1; row < rows_count; row++) {

List<WebElement> Columns\_row = rows\_table.get(row).findElements(By.tagName('td'))



int columns\_count = Columns\_row.size()

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

WebUI.verifyEqual(columns\_count, 8, FailureHandling.STOP\_ON_FAILURE)



for (int column = 0; column < columns_count; column++) {

    count++



    String celltext = Columns_row.get(column).getText()



    WebUI.verifyMatch(celltext, ExpectedValue, false, FailureHandling.OPTIONAL)



    if (celltext == ExpectedValue) {

        break Loop;

    }

}

}

why are you starting on 2nd row?

btw i did small test:
html used:

<html>  <head>  </head>  <body>    <div>Hello World!</div>		<table>			<tr>				<td>					<div _ngcontent5>						<!---->						<div _ngcontent5>							<p _ngcontent5>Some text2</p>						</div>						<!---->					</div>				</td>			</tr>		</table>  </body></html>

script used:

import org.openqa.selenium.Byimport org.openqa.selenium.WebDriverimport org.openqa.selenium.WebElementimport com.kms.katalon.core.model.FailureHandling as FailureHandlingimport com.kms.katalon.core.webui.driver.DriverFactoryimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIWebUI.openBrowser('c:\\\\Users\\\\somewhereOnMyDisk\\\\html\\\\hello.html')WebDriver driver = DriverFactory.getWebDriver()WebElement Table = driver.findElement(By.xpath('//table'))List<WebElement> rows_table = Table.findElements(By.tagName('tr'))def rows_count = rows_table.size()def count = 0println rows_countLoop:for (int row = 0; row < rows_count; row++) {	List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName('td'))	int columns_count = Columns_row.size()	println 'Number of cells In Row ' + row + ' are ' + columns_count	for (int column = 0; column < columns_count; column++) {		count++		def celltext = Columns_row.get(column).getText()		println celltext 	}}

and result in console:

08-10-2018 09:45:15 AM - [END]    - End action : openBrowser08-10-2018 09:45:15 AM - [START]  - Start action : Statement - driver = com.kms.katalon.core.webui.driver.DriverFactory.getWebDriver()08-10-2018 09:45:15 AM - [END]    - End action : Statement - driver = com.kms.katalon.core.webui.driver.DriverFactory.getWebDriver()08-10-2018 09:45:15 AM - [START]  - Start action : Statement - Table = driver.findElement(org.openqa.selenium.By.xpath("//table"))08-10-2018 09:45:15 AM - [END]    - End action : Statement - Table = driver.findElement(org.openqa.selenium.By.xpath("//table"))08-10-2018 09:45:15 AM - [START]  - Start action : Statement - rows_table = Table.findElements(org.openqa.selenium.By.tagName("tr"))08-10-2018 09:45:15 AM - [END]    - End action : Statement - rows_table = Table.findElements(org.openqa.selenium.By.tagName("tr"))08-10-2018 09:45:15 AM - [START]  - Start action : Statement - rows_count = rows_table.size()08-10-2018 09:45:15 AM - [END]    - End action : Statement - rows_count = rows_table.size()08-10-2018 09:45:15 AM - [START]  - Start action : Statement - count = 008-10-2018 09:45:15 AM - [END]    - End action : Statement - count = 008-10-2018 09:45:15 AM - [START]  - Start action : Statement - println(rows_count)108-10-2018 09:45:15 AM - [END]    - End action : Statement - println(rows_count)08-10-2018 09:45:15 AM - [START]  - Start action : Statement - For ([row = 0, row < rows_count, (row++)])08-10-2018 09:45:15 AM - [START]  - Start action : Statement - Columns_row = rows_table.get(row).findElements(org.openqa.selenium.By.tagName("td"))08-10-2018 09:45:15 AM - [END]    - End action : Statement - Columns_row = rows_table.get(row).findElements(org.openqa.selenium.By.tagName("td"))08-10-2018 09:45:15 AM - [START]  - Start action : Statement - columns_count = Columns_row.size()08-10-2018 09:45:15 AM - [END]    - End action : Statement - columns_count = Columns_row.size()08-10-2018 09:45:15 AM - [START]  - Start action : Statement - println("Number of cells In Row " + row + " are " + columns_count)Number of cells In Row 0 are 108-10-2018 09:45:15 AM - [END]    - End action : Statement - println("Number of cells In Row " + row + " are " + columns_count)08-10-2018 09:45:15 AM - [START]  - Start action : Statement - For ([column = 0, column < columns_count, (column++)])08-10-2018 09:45:15 AM - [START]  - Start action : Statement - (count++)08-10-2018 09:45:15 AM - [END]    - End action : Statement - (count++)08-10-2018 09:45:15 AM - [START]  - Start action : Statement - celltext = Columns_row.get(column).getText()08-10-2018 09:45:15 AM - [END]    - End action : Statement - celltext = Columns_row.get(column).getText()08-10-2018 09:45:15 AM - [START]  - Start action : Statement - println(celltext)Some text208-10-2018 09:45:15 AM - [END]    - End action : Statement - println(celltext)08-10-2018 09:45:15 AM - [END]    - End action : Statement - For ([column = 0, column < columns_count, (column++)])08-10-2018 09:45:15 AM - [END]    - End action : Statement - For ([row = 0, row < rows_count, (row++)])08-10-2018 09:45:15 AM - [PASSED] - Test Cases/__Sandbox/New Test Case - TableTest08-10-2018 09:45:15 AM - [END]    - End Test Case : Test Cases/__Sandbox/New Test Case - TableTes

i cannot see error in your code …

Ok, thank you Andrej Podhajský