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
0

There are 0 best solutions below