Home > Blockchain >  Getting error in Karate V1.1.0 org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (add)
Getting error in Karate V1.1.0 org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (add)

Time:07-05

I was using Karate v0.9.6 all this while. Recently I have upgraded to the version 1.1.0

One thing is troubling a lot is as bellows,

  • def responsevalue = response.body
  • def length = responsevalue.length
  • def number = []
  • eval for(var i = 0;i < length; i ) if(response.body[i].availablenumber > 10000) number.add(response.body[i].Id)

Error:- org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (add) on [] failed due to: Message not supported.

I'm sure I'm missing important part from the release notes. I would really appreciate any solution to this problem.

Many Thanks!

CodePudding user response:

First I'd like to say that loops like this are not recommended. Use filter() operations instead:

* def number = response.body.filter(x => x.availablenumber > 10000)

Refer: https://github.com/karatelabs/karate#json-transforms

Anyway, the change you need to make is : number.push() instead of number.add(): https://github.com/karatelabs/karate/wiki/1.0-upgrade-guide#java-api-s-for-maps-and-lists-are-no-longer-visible-within-js-blocks

  • Related