1

I am using maestro, I have created the following script, but when the code is run it gives me the following problem.

Can you give me a hand?

org.mozilla.javascript.EvaluatorException: Cannot modify a property of a sealed object: arr. (fetch.js#5)

test.yaml

appId: com.example
---
- runScript: fetch.js
- evalScript: "${console.log(output.result)}"

fetch.js

const response = http.get('http://localhost:9999/api/device-screen')
const elements = json(response.body).elements

function readPro(json, replaceText, props, filter, resorceIdFinal){
  arr = [], o = {}

  json.forEach(
      el => {
          resorceId = el.resourceId.replace(replaceText, '')
          if(props.includes(resorceId)){
              o[resorceId] = el.text
              if(resorceId === resorceIdFinal){ 
                  arr.push(o)
                  o = {}
              }
          }
      }
  )

 filtered = arr.reverse().filter(
      (s => o => 
          (k => !s.has(k) && s.add(k))
          (filter.map(k => o[k]).join('|'))
      )
      (new Set)
  )
  return filtered
}

res = readPro(
  elements, 
  'com.shazam.android:id/',
  ['title', 'subtitle', 'datetime'],
  ['title', 'subtitle'],
  'datetime'
)

output.result = res
3
  • 1
    I suspect this is an issue with the limited support of ES6 patterns of the RhinoJS engine that Maestro relies on. Have you tried switching to the GraalJS engine, which you can do via the config, and seeing if the problem persists? Commented Sep 5, 2023 at 9:21
  • Finally I solved it, but with many problems. Commented Sep 6, 2023 at 11:13
  • @Andrew: I also saw the message about the group on slack. ;) Commented Sep 6, 2023 at 11:15

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.