I am fetching the "Id" value from the previous page and storing it in text file. In the next page I am trying to iterate the table to find the particular Id by passing the value from the text file and trying to click on the status as "Accept" hyperlink. I have tried with the below steps but it throws me an error.
Code Snippet:
And def Id = commonClass.TextFile('TestData','Id')
* def list = scriptAll('tr td', '_.textContent')
* print list
* def fun = function(x, i){ if (x.contains(Id)) karate.set('index', i) }
* def xpath = "//table[@id='value']/tbody/tr/td[" + (index + 6) + "]/div/a"
* click(xpath)
Error Message:
"//table[@id='value']/tbody/tr/td[" + (index + 6) + "]/div/a", javax.script.ScriptException: ReferenceError: "index" is not defined in <eval> at line number 1 stack trace: jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470)