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)

3
  • my personal opinion - writing to a text file is not the right approach: stackoverflow.com/a/54593057/143475 - and there are plenty of answers on tables: stackoverflow.com/a/66718464/143475 Commented Mar 23, 2022 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! Commented Mar 24, 2022 at 3:28
  • sorry I can't - and please read this for my views on this subject: stackoverflow.com/a/47954946/143475 Commented Mar 24, 2022 at 10:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.