unable to choose icon on webtable

i need to select icon from webtable but no results can you help

this is the error
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {“method”:“xpath”,“selector”:“//*[@id=“grdSMEClassificationAgentActivity”]/tbody”}
(Session info: chrome=107.0.5304.107)

and this is code

‘Expected value from Table’
String ExpectedValue = 'والمكثف ’

WebDriver driver = DriverFactory.getWebDriver()

‘To locate table’
WebElement Table = driver.findElement(By.xpath(‘//*[@id=“grdSMEClassificationAgentActivity”]/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)) {
        'To locate anchor in the expected value matched row to perform action'



The above is the line that is failing, yet you have a huge delay just before it, so I would think you need to review the HTML of the table structure. If there is only one table on the page, see if:

WebElement Table = driver.findElement(By.xpath('//table/tbody'))

changes anything?

Also, if you put code on this forum, put 3 backticks (e.g. ```) on a line by themselves above your code and 3 more backticks on a line by themselves below your code. It makes your code easier to read. The backtick is found on the same key as the tilde (e.g. ~)

its passed but no selection happened

Can you do another small change to your program. Where you have break, can you change it to:

break Table;

I say this because you are down two layers of for loops, so in order to exit both loops, you need to add the label you used just before you started your first “for” loop.

**Table**: for (int i = 0; i < Rows.size(); i++) {

Now, if you mean my suggestion passed, then I again think you may have a pathway concern. However, you are using an id to detect the element you want to click on-- id are usually considered unique. Could you not just go to the element directly and not via the looping to click on the element?

The only concern I see is that the id has “_active_cell” on it. This seems to be an id that has changed state, like before it wasn’t “_active_cell”, but you selected it and now it is. Therefore, I think you need to check what the id really is before you click/select it. That may be your concern too.