Erros após atualização para versão 9.3.0

A versão 9.3.0 apresentou alguns problemas. Não está parando nos breakpoints e o foreach não está reconhecendo os arrays para executar o bloco. Além disso, alguns blocos estão sendo atropelados no processo, causando falhas em condicionais e a não espera pelo carregamento dos elementos na tela do navegador. Os blocos de clique e seleção de XPath também costumam apresentar dificuldades. Para contornar isso, sempre executo as ações e seleções usando executeScript e a solução apresentada no forum para usar com command: Store | target: FASTV1 | value: !replayspeed como solução de contorno. Para iterar num array, preciso utilizar o times, como alternativa ao foreach. Espero que esses bugs sejam corrigidos na nova versão o mais breve possível, pois a ferramenta é muito útil e tem uma boa performance.

Recentemente, ao rodar a macro, o código está quebrando no comando executeScript que segue abaixo:

[error]
Line 72: ipcPromise: onAsk timeout 3000 for cmd “PANEL_CALL_PLAY_TAB”, args {“ipcTimeout”:100,“ipcNoLaterThan”:3455622058638,“payload”:{“command”:“SET_STATUS”,“args”:{“status”:“PLAYING”}}}

JSON:

{
      "Command": "executeScript",
      "Target": "function getCurrentDateTime() {\n    var now = new Date();\n    var year = now.getFullYear();\n    var month = String(now.getMonth() + 1).padStart(2, '0');\n    var day = String(now.getDate()).padStart(2, '0');\n    var hours = String(now.getHours()).padStart(2, '0');\n    var minutes = String(now.getMinutes()).padStart(2, '0');\n    var seconds = String(now.getSeconds()).padStart(2, '0');\n\n    return year + month + day + hours + minutes + seconds;\n}\n\nconst dateTime = getCurrentDateTime().toString();\nreturn dateTime;",
      "Value": "dateTime",
      "Description": ""
}

I’m having the same problem here.

English version:

Version 9.3.0 had some problems. It is not stopping at breakpoints and foreach is not recognizing the arrays to execute the block. Furthermore, some blocks are being run over in the process, causing conditional failures and not waiting for elements to load on the browser screen. XPath’s click and select blocks also tend to present difficulties. To get around this, I always execute actions and selections using executeScript and the solution presented on the forum for use with command: Store | target: FASTV1 | value: !replayspeed as a workaround. To iterate over an array, I need to use times, as an alternative to foreach. I hope these bugs are fixed in the new version as soon as possible, as the tool is very useful and has good performance.

Recently, when running the macro, the code is breaking in the executeScript command below:

  1. Breakpoints → known issue, will be fixed asap

  2. For…each loop. Do you have a test case for me? I tested with the DemoCsvReadArray macro that ships with Ui.Vision, and it works fine.

  3. “Furthermore, some blocks are being run over in the process,…” → Do you have a test case for that? We are not aware of such an issue (yet).

  4. executeScript/PANEL_CALL_PLAY_TAB error - your command does not work for me, even on 9.2.9. I get a syntax error, some ] missing. Maybe this is a copy and paste issue. Can you please post a complete, small macro with the command inside?

@PhellipeSantos - What issue(s) do you see?

@admin admin, this is the error. As a result, the Macro stops, but there is no error. it freezes and nothing else happens.

  • [error][ignored]

Line 17: ipcPromise: onAsk timeout 5000 for cmd “PANEL_CALL_PLAY_TAB”, args {“ipcTimeout”:100,“ipcNoLaterThan”:3455742060918,“payload”:{“command”:“RUN_COMMAND”,“args”:{“command”:{“cmd”:“executeScript”,“target”:“return document.evaluate(‘//*[@id="paginationItemCountItemdiv_listar"]’, window.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue != null;”,“value”:“elementExists”,“description”:“”,“extra”:{“playHighlightElements”:true,“playScrollElementsIntoView”:true,“timeoutPageLoad”:120,“timeoutElement”:0,“timeoutDownload”:60,“timeoutDownloadStart”:10,“lastCommandOk”:false,“errorIgnore”:true,“waitForVisible”:false,“superFast”:true,“retryInfo”:{“retryCount”:0}}}}}}

Hi, do you have a small macro that I can run that shows the PANEL_CALL_PLAY_TAB error? Because so far, I can not recreate it here.

1. Excelente

2. Tentei simular o erro no script abaixo. Utilizei o comando executeScript para retornar um array mas o retorno vira uma string nas variáveis internas.

Macro:

{
  "Name": "teste2",
  "CreationDate": "2024-10-2",
  "Commands": [
    {
      "Command": "executeScript",
      "Target": "return [\"a\", \"b\", \"c\", \"d\"]",
      "Value": "myArray",
      "Description": ""
    },
    {
      "Command": "forEach",
      "Target": "myArray",
      "Value": "item",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${item}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }
  ]
}


3. Simulei o comportamento utilizando o length de um array, que mesmo estando vazio, entrou na estrutura condicional.

Macro:

{
  "Name": "teste1",
  "CreationDate": "2024-10-2",
  "Commands": [
    {
      "Command": "executeScript",
      "Target": "return []",
      "Value": "myArray",
      "Description": ""
    },
    {
      "Command": "if",
      "Target": "${myArray}.length > 0",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${myArray}.length",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "forEach",
      "Target": "myArray",
      "Value": "item",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${item}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }
  ]
}

4. Trata-se de um problema intermitente relacionado ao comando executeScript.

Outra observação: A versão 9.3.0 não apresenta a cor verde nos blocos executados com sucesso sem utilizar o comando: store | FASTV1 | !replayspeed.

no, my code is extensive and for a private website. However, the error occurs when the macro is running and the site crashes. Sometimes there is a DOM error and sometimes this giant executeScript error.

Ah, Ok, understand. We will look into this.

@MarlonRPA - can you please retest with the new V9.3.1? Does this solve the issues for you?

@PhellipeSantos the “site crash hangs Ui.Vision” issues is not related to the performance updates. But we will solve it with one of the next updates, too.

Infelizmente o erro relacionado ao reconhecimento de array no comando forEach persiste.

For me the “Foreach” command worked in 9.3.0 and now in 9.3.1.

Here I am running your test macros:

Estranho. Na primeira vez que executei esse código, o forEach apresentou um erro porque não reconhecia a variável como um array, mas sim como uma string.

Em seguida, tentei criar outra macro para executar um forEach usando um array retornado pelo comando executeScript, mas encontrei um erro curioso.

Macro:

{
  "Name": "teste2",
  "CreationDate": "2024-10-7",
  "Commands": [
    {
      "Command": "open",
      "Target": "www.google.com",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "executeScript",
      "Target": "return new Array('consultaPrazozListDataTable14:marca','consultaPrazozListDataTable15:marca','consultaPrazozListDataTable16:marca');",
      "Value": "myArray",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${myArray}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "forEach",
      "Target": "myArray",
      "Value": "item",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${item}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }
  ]
}

Log das execuções:

[status]
Playing macro teste2
[info]
Executing:  | open | www.google.com |  | 
[info]
Executing:  | executeScript | return new Array("1","2","3"); | myArray | 
[info]
Executing:  | forEach | myArray | item | 
[info]
Executing:  | echo | ${item} |  | 
[echo]
1
[info]
Executing:  | end |  |  | 
[info]
Executing:  | forEach | myArray | item | 
[info]
Executing:  | echo | ${item} |  | 
[echo]
2
[info]
Executing:  | end |  |  | 
[info]
Executing:  | forEach | myArray | item | 
[info]
Executing:  | echo | ${item} |  | 
[echo]
3
[info]
Executing:  | end |  |  | 
[info]
Executing:  | forEach | myArray | item | 
[info]
Macro completed (Runtime 6.58s)
[status]
Playing macro teste2
[info]
Executing:  | open | www.google.com |  | 
[info]
Executing:  | executeScript | const myArray = ['1','2','3'];
return myArray; | myArray | 
[info]
Executing:  | forEach | myArray | item | 
[info]
Executing:  | echo | ${item} |  | 
[echo]
1
[info]
Executing:  | end |  |  | 
[info]
Executing:  | forEach | myArray | item | 
[info]
Executing:  | echo | ${item} |  | 
[echo]
2
[info]
Executing:  | end |  |  | 
[info]
Executing:  | forEach | myArray | item | 
[info]
Executing:  | echo | ${item} |  | 
[echo]
3
[info]
Executing:  | end |  |  | 
[info]
Executing:  | forEach | myArray | item | 
[info]
Macro completed (Runtime 6.62s)
[status]
Playing macro teste2
[info]
Executing:  | open | www.google.com |  | 
[info]
Executing:  | executeScript | const myArray = ['1','2','3'];
return myArray; | myArray | 
[info]
Executing:  | echo | ${myArray} |  | 
[echo]
1,2,3
[info]
Executing:  | forEach | myArray | item | 
[info]
Executing:  | echo | ${item} |  | 
[echo]
1
[info]
Executing:  | end |  |  | 
[info]
Executing:  | forEach | myArray | item | 
[info]
Executing:  | echo | ${item} |  | 
[echo]
2
[info]
Executing:  | end |  |  | 
[info]
Executing:  | forEach | myArray | item | 
[info]
Executing:  | echo | ${item} |  | 
[echo]
3
[info]
Executing:  | end |  |  | 
[info]
Executing:  | forEach | myArray | item | 
[info]
Macro completed (Runtime 6.95s)
[status]
Playing macro teste2
[info]
Executing:  | open | www.google.com |  | 
[info]
Executing:  | executeScript | const myArray = ["consultaPrazozListDataTable14:marca","consultaPrazozListDataTable15:marca","consultaPrazozListDataTable16:marca"];
return myArray; | myArray | 
[error]
Line 2: Error in executeScript code: Refused to evaluate a string as JavaScript because this document requires 'Trusted Type' assignment.
[info]
Macro failed (Runtime 3.42s)
[status]
Playing macro teste2
[info]
Executing:  | open | www.google.com |  | 
[info]
Executing:  | executeScript | const myArray = ["consultaPrazozListDataTable14marca","consultaPrazozListDataTable15marca","consultaPrazozListDataTable16marca"];
return myArray; | myArray | 
[error]
Line 2: Error in executeScript code: Refused to evaluate a string as JavaScript because this document requires 'Trusted Type' assignment.
[info]
Macro failed (Runtime 3.27s)
[status]
Playing macro teste2
[info]
Executing:  | open | www.google.com |  | 
[info]
Executing:  | executeScript | const myArray = ['consultaPrazozListDataTable14marca','consultaPrazozListDataTable15marca','consultaPrazozListDataTable16marca'];
return myArray; | myArray | 
[error]
Line 2: Error in executeScript code: Refused to evaluate a string as JavaScript because this document requires 'Trusted Type' assignment.
[info]
Macro failed (Runtime 3.24s)
[status]
Playing macro teste2
[info]
Executing:  | open | www.google.com |  | 
[info]
Executing:  | executeScript | const myArray = new Array('consultaPrazozListDataTable14marca','consultaPrazozListDataTable15marca','consultaPrazozListDataTable16marca');
return myArray; | myArray | 
[error]
Line 2: Error in executeScript code: Refused to evaluate a string as JavaScript because this document requires 'Trusted Type' assignment.
[info]
Macro failed (Runtime 3.15s)
[status]
Playing macro teste2
[info]
Executing:  | open | www.google.com |  | 
[info]
Executing:  | executeScript | return new Array('consultaPrazozListDataTable14marca','consultaPrazozListDataTable15marca','consultaPrazozListDataTable16marca'); | myArray | 
[error]
Line 2: Error in executeScript code: Refused to evaluate a string as JavaScript because this document requires 'Trusted Type' assignment.
[info]
Macro failed (Runtime 3.33s)
[status]
Playing macro teste2
[info]
Executing:  | open | www.google.com |  | 
[info]
Executing:  | executeScript | return new Array('consultaPrazozListDataTable14\\:marca','consultaPrazozListDataTable15\\:marca','consultaPrazozListDataTable16\\:marca'); | myArray | 
[error]
Line 2: Error in executeScript code: Refused to evaluate a string as JavaScript because this document requires 'Trusted Type' assignment.
[info]
Macro failed (Runtime 4.78s)
[status]
Playing macro teste2
[info]
Executing:  | open | www.google.com |  | 
[info]
Executing:  | executeScript | return new Array('consultaPrazozListDataTable14\:marca','consultaPrazozListDataTable15\:marca','consultaPrazozListDataTable16\:marca'); | myArray | 
[error]
Line 2: Error in executeScript code: Refused to evaluate a string as JavaScript because this document requires 'Trusted Type' assignment.
[info]
Macro failed (Runtime 5.14s)
[status]
Playing macro teste2
[info]
Executing:  | open | www.google.com |  | 
[info]
Executing:  | executeScript | return new Array('consultaPrazozListDataTable14:marca','consultaPrazozListDataTable15:marca','consultaPrazozListDataTable16:marca'); | myArray | 
[error]
Line 2: Error in executeScript code: Refused to evaluate a string as JavaScript because this document requires 'Trusted Type' assignment.
[info]
Macro failed (Runtime 5.36s)

Trata-se de um código javascript válido, então não sei como a extensão trabalha nos retornos dos comandos executeScript.

Talvez o problema não esteja no forEach e sim no retorno do executeScript.

Há erros que talvez tenham a ver com permissões da extensão, devido às políticas do manifest versão 3.

video

Error in executeScript Refused to evaluate a string as JavaScript because unsafe-eval is not an allowed source of script in the following Content
Security Policy (CSP) directive: script-src ‘strict-dynamic’ ‘wasm-unsafe-eval’ https: ‘nonce-735…’

:point_right: executeScript runs inside the website. But here, the website blocks the Javascript execution. For example, Github.com does this. Solution: Use executeScript_Sandbox. It works just fine, as the Javascript is not executed inside the website.

In my case, I find onDownload command not working properly. It does not wait for the download process to complete, but continues instead, provoking further errors in the script (version 9.3.0).

Problema com Retorno de Array no executeScript do UI.Vision

Sim, há um comportamento curioso ao usar o comando executeScript no UI.Vision. Em alguns casos, o retorno de um array vem formatado como string, com caracteres de escape, como mostrado no exemplo abaixo:

executeScript | return new Array("a", "b", "c") | myArray
echo | ${myArray} |

Saída no console:

"[\"a\", \"b\", \"c\"]"

Isso equivale a usar JSON.stringify(myArray), que converte um array em uma string.

Para contornar isso, ao usar o comando executeScript_sandbox, posso transformar a string de volta em um array utilizando JSON.parse. Dessa forma, o forEach do UI.Vision consegue reconhecer a saída como um array e não como uma string.

Observação: Preciso utilizar o executeScript porque preciso extrair dados diretamente da página, como informações de linhas de uma tabela, e depois processar esse array com o forEach. Portanto, agora tenho um passo extra para garantir que o array seja identificado corretamente pelo UI.Vision.

Translated:

Problem with Array Return in UI.Vision’s executeScript Yes, there is a curious behavior when using the executeScript command in UI.Vision. In some cases, the return of an array is formatted as a string, with escape characters, as shown in the example below:

executeScript | return new Array(“a”, “b”, “c”) | myArray echo | ${myArray} |

Console output: “["a", "b", "c"]”

This is equivalent to using JSON.stringify(myArray), which converts an array to a string. To get around this, when using the executeScript_sandbox command, I can transform the string back into an array using JSON.parse. This way, UI.Vision’s forEach can recognize the output as an array and not as a string.

Note: I need to use executeScript because I need to extract data directly from the page, such as row information from a table, and then process this array with forEach. So now I have an extra step to make sure the array is identified correctly by UI.Vision.