How to fix this error in web tables

I want to select the specific row in the data tables which is For release. I already follow the syntax in your documention but the error is:

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {“method”:“xpath”,“selector”:“tblLoanList”}

Here is my code:
String ExpectedValue = ‘For Release’

WebDriver driver = DriverFactory.getWebDriver()

‘To locate table’
WebElement Table = driver.findElement(By.xpath(‘tblLoanList’))

'To locate rows of table it will Capture all the rows available in the table ’
List Rows = Table.findElements(By.tagName(‘tr’))

println('No. of rows: ’ + Rows.size())

‘Find a matching text in a table and performing action’

‘Loop will execute for all the rows of the table’
table: for (int i = 0; i < Rows.size(); i++) {
‘To locate columns(cells) of that specific row’
List Cols = Rows.get(i).findElements(By.tagName(‘td’))

for (int j = 0; j < Cols.size(); j++) {
    'Verifying the expected text in the each cell'
    if (Cols.get(j).getText().equalsIgnoreCase(ExpectedValue)) {
        String AccountNumber = Cols.get(0).getText()

        'To locate anchor in the expected value matched row to perform action'
        Cols.get(10).findElement(By.tagName(AccountNumber + 'edit')).click()

        break
    }
}

}

Attached file is the xpath of the element

i would assume the xpath you need would be something along the lines of “//table[@id=‘tblLoanList’]”
so
WebElement Table = driver.findElement(By.xpath("//table[@id=‘tblLoanList’]"))

Thank you for the response but its not working :frowning:

my other guess would then be that you are trying to find the element too fast, try to wait for a few seconds before trying
beyond that, the xpath looks correct to me, so it should be a different error that occurs
if it turns out you were trying too fast, you may want to look into waiting for a specific condition(element present)

I would agree with @kenzie.rigole and you should put a waitFor or delay statement until your web tables has formed on the page. Also, you need to change the XPath statement.

Instead, this should be something like below. Your XPath has not gotten you “low” enough in the web table to “see” the “tr” tag just “below” (but you want the “tr” tags in the body, not the header area).

'To locate table'
WebElement Table = driver.findElement(By.xpath('//table[@id="tblLoanList"]/tbody'))

One final point; you have two for loops happening but you only use “break”. This will only leave the inner loop. To break out of both loops, you need to “jump” to the label, which you have as “table”. So you should use, break table;

Thank you for the response I Already apply your suggestions but the code is not working
here is my code:
String ExpectedValue = ‘For Release’

WebDriver driver = DriverFactory.getWebDriver()

WebUI.delay(10)

‘To locate table’
WebElement Table = WebElement Table = driver.findElement(By.xpath(’//table[@id=“tblLoanList”]/tbody’))

'To locate rows of table it will Capture all the rows available in the table ’
List Rows = Table.findElements(By.tagName(‘tr’))

println('No. of rows: ’ + Rows.size())

‘Find a matching text in a table and performing action’

‘Loop will execute for all the rows of the table’
table: for (int i = 0; i < Rows.size(); i++) {
‘To locate columns(cells) of that specific row’
List Cols = Rows.get(i).findElements(By.tagName(‘td’))

for (int j = 0; j < Cols.size(); j++) {
    'Verifying the expected text in the each cell'
    if (Cols.get(j).getText().equalsIgnoreCase(ExpectedValue)) {
        String AccountNumber = Cols.get(0).getText()

        'To locate anchor in the expected value matched row to perform action'
        Cols.get(10).findElement(By.tagName(AccountNumber + 'edit')).click()

        break table;
    }
}

}

Here is the error:

Elapsed time: 25.191s

Test Cases/Loan Release FAILED.
Reason:
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {“method”:“xpath”,“selector”:"//table[@id=“tblLoanList”]/tbody"}

@josh.pena

Don’t you have <iframe> element in the web page? If yes, you should WebUI.switchToFrame()

Where I can insert this code to my codes?

Do you find any <iframe> in your target HTML?

Where I can find the iframe sir? im newbie in katalon can you give me a sample screenshots

I am sure that you know how to use Chrome’s DevTools, as you attached the following image.

In the DevTool, in the “Elements” tab, you can scroll up/down the HTML source. Please read the HTML source and find any <iframe> element there. You might have none, or you may have many, I don’t know. Just tell us if you find any.

I think here it is

Is the <table> element of your interest inside the <iframe> element?

Inside your test case, anywhere after you open browser, before you call driver.findElement(By.xpath('//table[@id="tblLoadList"]/tbody')).

same error
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {“method”:“xpath”,“selector”:"//table[@id=“tblLoanList”]/tbody"}

here is my code :
String ExpectedValue = ‘For Release’

WebDriver driver = DriverFactory.getWebDriver()

WebUI.waitForElementPresent(findTestObject(‘Loan Release/Page_Core/tbLoanList’), 10)

‘To locate table’

driver.findElement(By.xpath(’//table[@id=“tblLoanList”]/tbody’)).

'To locate rows of table it will Capture all the rows available in the table ’
List Rows = Table.findElements(By.tagName(‘tr’))

println('No. of rows: ’ + Rows.size())

‘Find a matching text in a table and performing action’

‘Loop will execute for all the rows of the table’
table: for (int i = 0; i < Rows.size(); i++) {
‘To locate columns(cells) of that specific row’
List Cols = Rows.get(i).findElements(By.tagName(‘td’))

for (int j = 0; j < Cols.size(); j++) {
    'Verifying the expected text in the each cell'
    if (Cols.get(j).getText().equalsIgnoreCase(ExpectedValue)) {
        String AccountNumber = Cols.get(0).getText()

        'To locate anchor in the expected value matched row to perform action'
        Cols.get(10).findElement(By.tagName(AccountNumber + 'edit')).click()

        break table;
    }
}

}

yes the table element is inside the iframe

Please use the code formatting syntax in your posts for better readability.

You haven’t used WebUI.switchToFrame() yet, have you?

I’ve already use the WebUI.switchToFrame but here is the error:

Could not find which method switchToFrame() to invoke from this list:

Code:
WebUI.switchToFrame()
String ExpectedValue = ‘For Release’

WebDriver driver = DriverFactory.getWebDriver()

WebUI.waitForElementPresent(findTestObject(‘Loan Release/Page_Core/tbLoanList’), 10)

‘To locate table’

driver.findElement(By.xpath(’//table[@id=“tblLoanList”]/tbody’)).

'To locate rows of table it will Capture all the rows available in the table ’
List Rows = Table.findElements(By.tagName(‘tr’))

println('No. of rows: ’ + Rows.size())

‘Find a matching text in a table and performing action’

‘Loop will execute for all the rows of the table’
table: for (int i = 0; i < Rows.size(); i++) {
‘To locate columns(cells) of that specific row’
List Cols = Rows.get(i).findElements(By.tagName(‘td’))

for (int j = 0; j < Cols.size(); j++) {
    'Verifying the expected text in the each cell'
    if (Cols.get(j).getText().equalsIgnoreCase(ExpectedValue)) {
        String AccountNumber = Cols.get(0).getText()

        'To locate anchor in the expected value matched row to perform action'
        Cols.get(10).findElement(By.tagName(AccountNumber + 'edit')).click()

        break table;
    }
}

}

Please read the document:

you need to specify at least 2 arguments.

And you must locate the line of calling WebUI.switchToFrame after you launch the browser and navigate to the URL.