Unable to find table element

Hi
I am working on a Katalon studio test case and I need to find a table element but I cant. Whenever I try to do it, it fails:
This is the error: “no such element: Unable to locate element”

To fix this I tried various things:

  1. try to find table by id
  2. try to find element by xpath
  3. try to find element by full xpath
  4. try and follow this:
    Trying to find object by Xpath "How to handle Web Tables"

None of this worked for me.
One of the things I usually do is to try and use the spy web tool. This usually helps me a lot but whenever I try to locate the element with this, the tool can not find it. (no red border shows up in element)

This is the code I am using:
WebUI.callTestCase(findTestCase(‘Veterinaria/7-Ingreso y validacion de resultados 2’), [:], FailureHandling.STOP_ON_FAILURE)

WebDriver driver = DriverFactory.getWebDriver()

WebElement Table = driver.findElement(By.xpath('/html/body/form/div[2]/div[2]/div/div/div/div/div[2]/div/table/tbody/tr[2]/td/div/div/div/div/div/div/div/div/table/tbody/tr[2]/td/div/div/table/tbody/tr/td/table'))
//WebElement Table = driver.findElement(By.xpath("//table[@id=\'Grid1ContainerTbl\']/tbody"))
List<WebElement> Rows = Table.findElements(By.tagName('tr'))
//List<WebElement> tr_withInput = Table.findElements(By.xpath('//tr[*//input[contains(@id, \'vRESULTADOVALOR_\')]]'))
table: for (int i = 1; i < Rows.size(); i++) {
	println('Aqui estoy ' + Rows(i))
	TestObject toV = new TestObject()
	String objectXpathV = CustomKeywords.'keywordPrueba.CustomFunction.getDynamicObjects'('//input[@id=\'vRESULTADOVALOR_', i)
	toV.addProperty('xpath', ConditionType.EQUALS, objectXpathV)
	if (WebUI.verifyElementNotPresent(toV, 5, FailureHandling.OPTIONAL)) {
		break
	} else {
		WebElement elementPrueba = WebUiCommonHelper.findWebElement(toV, 5)

		String textInsideInputBox = elementPrueba.getAttribute('value')

		if (textInsideInputBox.isEmpty()) {
			CustomKeywords.'keywordPrueba.CustomFunction.clickUsingJS'(toV, 5)

			WebUI.executeJavaScript('arguments[0].value=\'12\'', Arrays.asList(elementPrueba))
		}
	}
}

This is the html code:

If you have any suggestions on how to resolve this, I would be very happy
Thanks

@guillenoble59

  1. try reducing the By.xpath statement to just, By.xpath(’//table[@id=“TABLE6_0001”] /tbody’)
  2. try starting your loop at zero instead of one
  3. you use “getAttribute”. Should you try “getText” instead?
  4. try splitting the row down into column components, such as:
    ‘To locate columns(cells) of that specific row’
    List#WebElement# Columns_row = rows_table.get(irow).findElements(By.tagName(‘td’)) (you would have to change the hashmark to greater than and less than symbols to have the proper format for the List as a Generic but the proper format makes it disappear within this thread)

and then use some means to get the specific column you want:
‘retrieve text from column 2 that has info I want (zero based)’
someText = Columns_row.get(1).getText()

Saying that, I haven’t used some of your statements myself.

I think you are trying to do this on Chrome.You could try to change the xpath that the last node is not on the span. You can try to create new object in Object Repository with attribute is xpath like this:

(I haven’t seen your table so that this is just for reference)

//table[contains(@class,'gx-tab-spacing')]//tr[${row}]/td[${column}][.//span[contains(.,'Acidos Bill')]

and then you try to call the test case and provide the parameter for row and column. (note that the last node in the xpath above is td, not span)