Hi team im getting an error in capturing the td values, can anyone suggest me the solution for this.

2023-01-10 19:15:03.814 DEBUG testcase.Digital Assets_TABLEDATA - 28: Table = driver.findElement(By.xpath(“//[@id=“MUgmPNjz_content”]/div/div/div[3]/table/tbody/tr[3]/td”))
2023-01-10 19:15:04.228 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/2023_D_WHOLEDASHBOARD/Digital Assets_TABLEDATA FAILED.
Reason:
org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression //[@id=“MUgmPNjz_content”]/div/div/div[3]/table/tbody/tr[3]/td because of the following error:
SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘//[@id=“MUgmPNjz_content”]/div/div/div[3]/table/tbody/tr[3]/td’ is not a valid XPath expression.
(Session info: chrome=108.0.5359.125)
For documentation on this error, please visit: /documentation/webdriver/troubleshooting/errors/
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘01HW2106426’, ip: ‘172.19.174.228’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_282’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 108.0.5359.125, chrome: {chromedriverVersion: 107.0.5304.62 (1eec40d3a576…, userDataDir: C:\Users\2193838\AppData\Lo…}, goog:chromeOptions: {debuggerAddress: localhost:57905}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: e4c8d025450b669fcb367b446ff6b469
*** Element info: {Using=xpath, value=//[@id=“MUgmPNjz_content”]/div/div/div[3]/table/tbody/tr[3]/td}
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:19)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at org.openqa.selenium.support.events.EventFiringWebDriver.lambda$new$1(EventFiringWebDriver.java:105)
at com.sun.proxy.$Proxy11.findElement(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:194)
at org.openqa.selenium.WebDriver$findElement.call(Unknown Source)
at Digital Assets_TABLEDATA.run(Digital Assets_TABLEDATA:151)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1673358175328.run(TempTestCase1673358175328.groovy:25)

The above says that you do not have a valid Xpath. Add an asterisk (e.g. *) between the double slash and the first straight bracket, like below (the asterisk replaces any tag that might be used):

//*[@id="MUgmPNjz_content"]/div/div/div[3]/table/tbody/tr[3]/td

I also think this is not a “Bugs Report”.

Hi Grylion,
Im using this code
WebUI.click(findTestObject(‘Form Search/button_Search’))

WebUI.delay(10)

//String ExpectedValue = ‘34816-01’

String ExpectedValue = findTestData(‘wholedashboards/Marketo’).getValue(‘HANA SQL Query’,3)

WebUI.delay(10)
WebDriver driver = DriverFactory.getWebDriver()
WebElement Table = driver.findElement(By.xpath(‘Object Repository/Digital Assets/Digital Assets_TABLEDATA/td_466’))

List links = Table.findElements(By.xpath(‘//tr[3]/td’))

for (int j = 0; j < links.size(); j++) {
‘Verifying the expected text in the each cell’
if (links.get(j).getText().equalsIgnoreCase(ExpectedValue)) {
‘To locate anchor in the expected value matched row to perform action’
links.get(j).click()

	WebUI.delay(5)

	WebUI.verifyElementPresent(findTestObject('Form Search/h2_Filing History'), 0)

	break
}

}

To get the table values but its not coming its showing error in the findelement By.xpath for taking the value in that i have also given the direct xpath still its not working.

I have to verify the value from sql and table data in qlik dashboards if you have anyother code kindly share with me.

If you look at the two lines of code above, the lower one is an actual “xpath”. The upper one is not. It is the pathway to an element (a TestObject) in the Object Repository.

How about trying the below to replace the top one above?

WebElement Table = WebUI.findWebElement(findTestObject('Object Repository/Digital Assets/Digital Assets_TABLEDATA/td_466'))
Maybe like:
WebUI.click(findTestObject('Form Search/button_Search'))

WebUI.delay(10)

//String ExpectedValue = ‘34816-01’

String ExpectedValue = findTestData('wholedashboards/Marketo').getValue('HANA SQL Query',3)

WebUI.delay(10)
WebDriver driver = DriverFactory.getWebDriver()
WebElement Table = WebUI.findWebElement(findTestObject('Object Repository/Digital Assets/Digital Assets_TABLEDATA/td_466'))

List<WebElement> links = Table.findElements(By.xpath('//tr[3]/td'))

for (int j = 0; j < links.size(); j++) {
    'Verifying the expected text in the each cell'
    if (links.get(j).getText().equalsIgnoreCase(ExpectedValue)) {
        'To locate anchor in the expected value matched row to perform action'
        links.get(j).click()

	    WebUI.delay(5)

	    WebUI.verifyElementPresent(findTestObject('Form Search/h2_Filing History'), 0)

	    break
    }
}

You can help us to read your code if you put 3 backticks (like ``` ) on a line by themselves above your code and 3 backticks on on a line by themselves below your code. The backtick is found on the same key as the tilde (like ~ ).