0

enter image description here

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)

Ken White
  • 123,280
  • 14
  • 225
  • 444
oliver
  • 75
  • 6
  • my personal opinion - writing to a text file is not the right approach: https://stackoverflow.com/a/54593057/143475 - and there are plenty of answers on tables: https://stackoverflow.com/a/66718464/143475 – Peter Thomas Mar 23 '22 at 18:25
  • @PeterThomas Thanks for your response. Actually I am not storing the values from the table. In the above case, the "ID" value is already stored in text file. I want to locate that particular "ID" in this table and I want to click the "Accept" hyperlink for that particular ID. Kindly Assist me on this! – oliver Mar 24 '22 at 03:28
  • sorry I can't - and please read this for my views on this subject: https://stackoverflow.com/a/47954946/143475 – Peter Thomas Mar 24 '22 at 10:23

0 Answers0