Detalle executeScript

Al usar el elemento “executeScript” almaceno un valor en objeto como lo siguiente {x: valor, y:valor}. y trato de procesar ese objeto en “invokeCode” y al imprimir el resultado de me arroja {
“result”: {
“className”: “Object”,
“description”: “Object”,
“objectId”: “-464087585395958312.3.1”,
“type”: “object”
}
}

CABE MENCIONAR QUE FUNCIONABA BIEN, ASI COMO ESTA.


image

I’m not sure what the issue is. Could you create a small example workflow and share here, that demonstrates the issue ? ( export in OpenRPA and upload the json file )

1.- Estoy entrando a una página web.
2.- Realizo unos procesos para encontrar la posición de unos elementos.
3.- almacena el resultado en la variable de salida del “executeScript”.
e intento manipularlo en "invoquecode " para acceder a la variable y obtener los resultados del objeto en variables distintas.
NOTA: Ejecute este flujo en otro pc con openRPA desconectado de openflow.

no pode enviar el archivo detalleExecuteScript.json

{"save_output":false,"send_output":false,"queue":null,"Xaml":"<Activity mc:Ignorable=\"sap sap2010 sads\" x:Class=\"detalleExecuteScript\" mva:VisualBasic.Settings=\"{x:Null}\" sap2010:WorkflowViewState.IdRef=\"New_Workflow_1\"\r\n xmlns=\"http://schemas.microsoft.com/netfx/2009/xaml/activities\"\r\n xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\r\n xmlns:mva=\"clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities\"\r\n xmlns:on=\"clr-namespace:OpenRPA.NM;assembly=OpenRPA.NM\"\r\n xmlns:osa=\"clr-namespace:OpenRPA.Script.Activities;assembly=OpenRPA.Script\"\r\n xmlns:sads=\"http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger\"\r\n xmlns:sap=\"http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation\"\r\n xmlns:sap2010=\"http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation\"\r\n xmlns:scg=\"clr-namespace:System.Collections.Generic;assembly=mscorlib\"\r\n xmlns:sco=\"clr-namespace:System.Collections.ObjectModel;assembly=mscorlib\"\r\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">\r\n  <TextExpression.NamespacesForImplementation>\r\n    <sco:Collection x:TypeArguments=\"x:String\">\r\n      <x:String>System</x:String>\r\n      <x:String>System.Xml</x:String>\r\n      <x:String>OpenRPA</x:String>\r\n      <x:String>System.Data</x:String>\r\n      <x:String>System.Linq</x:String>\r\n      <x:String>Microsoft.VisualBasic</x:String>\r\n      <x:String>System.Activities</x:String>\r\n    </sco:Collection>\r\n  </TextExpression.NamespacesForImplementation>\r\n  <TextExpression.ReferencesForImplementation>\r\n    <sco:Collection x:TypeArguments=\"AssemblyReference\">\r\n      <AssemblyReference>mscorlib</AssemblyReference>\r\n      <AssemblyReference>System.Xml</AssemblyReference>\r\n      <AssemblyReference>OpenRPA</AssemblyReference>\r\n      <AssemblyReference>OpenRPA.Interfaces</AssemblyReference>\r\n      <AssemblyReference>System.Data</AssemblyReference>\r\n      <AssemblyReference>System.Core</AssemblyReference>\r\n      <AssemblyReference>Microsoft.VisualBasic</AssemblyReference>\r\n      <AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>\r\n      <AssemblyReference>System.Activities</AssemblyReference>\r\n    </sco:Collection>\r\n  </TextExpression.ReferencesForImplementation>\r\n  <Sequence sap2010:WorkflowViewState.IdRef=\"Sequence_1\">\r\n    <Sequence.Variables>\r\n      <Variable x:TypeArguments=\"x:Object\" Name=\"objetoResult\" />\r\n    </Sequence.Variables>\r\n    <on:OpenURL NewTab=\"{x:Null}\" UserDataFolderMode=\"{x:Null}\" UserDataFolderPath=\"{x:Null}\" Browser=\"chrome\" sap2010:WorkflowViewState.IdRef=\"OpenURL_1\" Url=\"https://www.google.com.mx/\" />\r\n    <on:ExecuteScript FrameId=\"{x:Null}\" Results=\"{x:Null}\" Browser=\"chrome\" DisplayName=\"jsEnNavegador - Execute Script\" sap2010:WorkflowViewState.IdRef=\"ExecuteScript_1\" Result=\"[objetoResult]\" Script=\"//creando un objeto dentro del navegador con js &quot;ExecuteScript&quot;&#xA;&#xA;objetoResult = {key1: &quot;valor 1&quot;, key2: &quot;valor2&quot;}\" />\r\n    <Delay Duration=\"00:00:05\" sap2010:WorkflowViewState.IdRef=\"Delay_1\" />\r\n    <osa:InvokeCode PipelineOutput=\"{x:Null}\" Code=\"Console.WriteLine(objetoResult)\" sap2010:WorkflowViewState.IdRef=\"InvokeCode_1\" Language=\"VB\">\r\n      <osa:InvokeCode.namespaces>\r\n        <x:Array Type=\"x:String\">\r\n          <x:String>System</x:String>\r\n          <x:String>System.Xml</x:String>\r\n          <x:String>OpenRPA</x:String>\r\n          <x:String>System.Data</x:String>\r\n          <x:String>System.Linq</x:String>\r\n          <x:String>Microsoft.VisualBasic</x:String>\r\n          <x:String>System.Activities</x:String>\r\n          <x:String>System.Collections</x:String>\r\n          <x:String>System.Collections.Generic</x:String>\r\n        </x:Array>\r\n      </osa:InvokeCode.namespaces>\r\n    </osa:InvokeCode>\r\n    <sads:DebugSymbol.Symbol>dw1DOlxFbXB0eS54YW1sAA==</sads:DebugSymbol.Symbol>\r\n  </Sequence>\r\n  <sap2010:WorkflowViewState.ViewStateManager>\r\n    <sap2010:ViewStateManager>\r\n      <sap2010:ViewStateData Id=\"OpenURL_1\" sap:VirtualizedContainerService.HintSize=\"200,55\" />\r\n      <sap2010:ViewStateData Id=\"ExecuteScript_1\" sap:VirtualizedContainerService.HintSize=\"200,55\" />\r\n      <sap2010:ViewStateData Id=\"Delay_1\" sap:VirtualizedContainerService.HintSize=\"200,22\" />\r\n      <sap2010:ViewStateData Id=\"InvokeCode_1\" sap:VirtualizedContainerService.HintSize=\"200,55\" />\r\n      <sap2010:ViewStateData Id=\"Sequence_1\" sap:VirtualizedContainerService.HintSize=\"222,431\">\r\n        <sap:WorkflowViewStateService.ViewState>\r\n          <scg:Dictionary x:TypeArguments=\"x:String, x:Object\">\r\n            <x:Boolean x:Key=\"IsExpanded\">True</x:Boolean>\r\n          </scg:Dictionary>\r\n        </sap:WorkflowViewStateService.ViewState>\r\n      </sap2010:ViewStateData>\r\n      <sap2010:ViewStateData Id=\"New_Workflow_1\" sap:VirtualizedContainerService.HintSize=\"262,511\" />\r\n    </sap2010:ViewStateManager>\r\n  </sap2010:WorkflowViewState.ViewStateManager>\r\n</Activity>","culture":"es","Parameters":[],"Serializable":true,"background":false,"Filename":"NewWorkflow.xaml","projectandname":"detalle en executeScript/detalleExecuteScript","FilePath":"C:\\Users\\dhsolis\\Documents\\OpenRPA\\detalle en executeScript\\NewWorkflow.xaml","projectid":"f0fbfea1-2012-42b8-8a3e-75a5c94e9f76","name":"detalleExecuteScript","_id":"88605a60-d836-4dfb-8408-fac7d42c8bc9","_type":"workflow","_modified":"2022-11-28T18:20:52.7700546-06:00","_modifiedby":null,"_modifiedbyid":null,"_created":"0001-01-01T00:00:00","_createdby":null,"_createdbyid":null,"_acl":null,"_encrypt":null,"_version":7}

Hey
Thank you for the example. Now i understood what you where trying to do.
You are not returning anything from the function, ( execute script does not run in the robot like Invoke Code does, it runs in the browser, so we need to return a result )
Also, right now, the chrome extension does not support sending objects only simple types like string, bool and numbers.
So i modified your example to return the object as a string
I also added an example on how to convert the json to an object you can work with

{"save_output":false,"send_output":false,"queue":null,"Xaml":"<Activity mc:Ignorable=\"sap sap2010 sads\" x:Class=\"detalleExecuteScript2\" mva:VisualBasic.Settings=\"{x:Null}\" sap2010:WorkflowViewState.IdRef=\"New_Workflow_1\"\r\n xmlns=\"http://schemas.microsoft.com/netfx/2009/xaml/activities\"\r\n xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\r\n xmlns:mva=\"clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities\"\r\n xmlns:njl=\"clr-namespace:Newtonsoft.Json.Linq;assembly=Newtonsoft.Json\"\r\n xmlns:on=\"clr-namespace:OpenRPA.NM;assembly=OpenRPA.NM\"\r\n xmlns:osa=\"clr-namespace:OpenRPA.Script.Activities;assembly=OpenRPA.Script\"\r\n xmlns:sads=\"http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger\"\r\n xmlns:sap=\"http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation\"\r\n xmlns:sap2010=\"http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation\"\r\n xmlns:scg=\"clr-namespace:System.Collections.Generic;assembly=mscorlib\"\r\n xmlns:sco=\"clr-namespace:System.Collections.ObjectModel;assembly=mscorlib\"\r\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">\r\n  <TextExpression.NamespacesForImplementation>\r\n    <sco:Collection x:TypeArguments=\"x:String\">\r\n      <x:String>System</x:String>\r\n      <x:String>System.Xml</x:String>\r\n      <x:String>OpenRPA</x:String>\r\n      <x:String>System.Data</x:String>\r\n      <x:String>System.Linq</x:String>\r\n      <x:String>Microsoft.VisualBasic</x:String>\r\n      <x:String>System.Activities</x:String>\r\n      <x:String>Newtonsoft.Json.Linq</x:String>\r\n      <x:String>Newtonsoft.Json</x:String>\r\n    </sco:Collection>\r\n  </TextExpression.NamespacesForImplementation>\r\n  <TextExpression.ReferencesForImplementation>\r\n    <sco:Collection x:TypeArguments=\"AssemblyReference\">\r\n      <AssemblyReference>mscorlib</AssemblyReference>\r\n      <AssemblyReference>System.Xml</AssemblyReference>\r\n      <AssemblyReference>OpenRPA</AssemblyReference>\r\n      <AssemblyReference>OpenRPA.Interfaces</AssemblyReference>\r\n      <AssemblyReference>System.Data</AssemblyReference>\r\n      <AssemblyReference>System.Core</AssemblyReference>\r\n      <AssemblyReference>Microsoft.VisualBasic</AssemblyReference>\r\n      <AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>\r\n      <AssemblyReference>System.Activities</AssemblyReference>\r\n      <AssemblyReference>Newtonsoft.Json</AssemblyReference>\r\n      <AssemblyReference>System</AssemblyReference>\r\n      <AssemblyReference>System.Memory</AssemblyReference>\r\n      <AssemblyReference>Microsoft.Bcl.AsyncInterfaces</AssemblyReference>\r\n      <AssemblyReference>Microsoft.Bcl.HashCode</AssemblyReference>\r\n      <AssemblyReference>System.ValueTuple</AssemblyReference>\r\n      <AssemblyReference>System.ServiceModel</AssemblyReference>\r\n      <AssemblyReference>System.ComponentModel.Composition</AssemblyReference>\r\n      <AssemblyReference>System.Net.WebSockets.Client.Managed</AssemblyReference>\r\n      <AssemblyReference>System.Runtime.WindowsRuntime</AssemblyReference>\r\n    </sco:Collection>\r\n  </TextExpression.ReferencesForImplementation>\r\n  <Sequence sap2010:WorkflowViewState.IdRef=\"Sequence_1\">\r\n    <Sequence.Variables>\r\n      <Variable x:TypeArguments=\"x:Object\" Name=\"objetoResult\" />\r\n      <Variable x:TypeArguments=\"njl:JObject\" Name=\"jobj\" />\r\n    </Sequence.Variables>\r\n    <on:OpenURL NewTab=\"{x:Null}\" UserDataFolderMode=\"{x:Null}\" UserDataFolderPath=\"{x:Null}\" Browser=\"chrome\" sap2010:WorkflowViewState.IdRef=\"OpenURL_1\" Url=\"https://www.google.com.mx/\" />\r\n    <on:ExecuteScript FrameId=\"{x:Null}\" Results=\"{x:Null}\" Browser=\"chrome\" DisplayName=\"jsEnNavegador - Execute Script\" sap2010:WorkflowViewState.IdRef=\"ExecuteScript_1\" Result=\"[objetoResult]\" Script=\"//creando un objeto dentro del navegador con js &quot;ExecuteScript&quot;&#xA;&#xA;objetoResult = {key1: &quot;valor 1&quot;, key2: &quot;valor2&quot;}&#xA;JSON.stringify(objetoResult)\" />\r\n    <Assign sap2010:WorkflowViewState.IdRef=\"Assign_1\">\r\n      <Assign.To>\r\n        <OutArgument x:TypeArguments=\"njl:JObject\">[jobj]</OutArgument>\r\n      </Assign.To>\r\n      <Assign.Value>\r\n        <InArgument x:TypeArguments=\"njl:JObject\">[Newtonsoft.Json.Linq.JObject.Parse(objetoResult.ToString)]</InArgument>\r\n      </Assign.Value>\r\n    </Assign>\r\n    <WriteLine sap2010:WorkflowViewState.IdRef=\"WriteLine_1\" Text=\"[jobj(&quot;key1&quot;).ToString]\" />\r\n    <WriteLine sap2010:WorkflowViewState.IdRef=\"WriteLine_2\" Text=\"[jobj(&quot;key2&quot;).ToString]\" />\r\n    <osa:InvokeCode PipelineOutput=\"{x:Null}\" Code=\"Console.WriteLine(objetoResult)\" sap2010:WorkflowViewState.IdRef=\"InvokeCode_1\" Language=\"VB\">\r\n      <osa:InvokeCode.namespaces>\r\n        <x:Array Type=\"x:String\">\r\n          <x:String>System</x:String>\r\n          <x:String>System.Xml</x:String>\r\n          <x:String>OpenRPA</x:String>\r\n          <x:String>System.Data</x:String>\r\n          <x:String>System.Linq</x:String>\r\n          <x:String>Microsoft.VisualBasic</x:String>\r\n          <x:String>System.Activities</x:String>\r\n          <x:String>System.Collections</x:String>\r\n          <x:String>System.Collections.Generic</x:String>\r\n        </x:Array>\r\n      </osa:InvokeCode.namespaces>\r\n    </osa:InvokeCode>\r\n    <sads:DebugSymbol.Symbol>dw1DOlxFbXB0eS54YW1sAA==</sads:DebugSymbol.Symbol>\r\n  </Sequence>\r\n  <sap2010:WorkflowViewState.ViewStateManager>\r\n    <sap2010:ViewStateManager>\r\n      <sap2010:ViewStateData Id=\"OpenURL_1\" sap:VirtualizedContainerService.HintSize=\"242,55\" />\r\n      <sap2010:ViewStateData Id=\"ExecuteScript_1\" sap:VirtualizedContainerService.HintSize=\"242,55\" />\r\n      <sap2010:ViewStateData Id=\"Assign_1\" sap:VirtualizedContainerService.HintSize=\"242,60\" />\r\n      <sap2010:ViewStateData Id=\"WriteLine_1\" sap:VirtualizedContainerService.HintSize=\"242,61\" />\r\n      <sap2010:ViewStateData Id=\"WriteLine_2\" sap:VirtualizedContainerService.HintSize=\"242,61\" />\r\n      <sap2010:ViewStateData Id=\"InvokeCode_1\" sap:VirtualizedContainerService.HintSize=\"242,55\" />\r\n      <sap2010:ViewStateData Id=\"Sequence_1\" sap:VirtualizedContainerService.HintSize=\"264,671\">\r\n        <sap:WorkflowViewStateService.ViewState>\r\n          <scg:Dictionary x:TypeArguments=\"x:String, x:Object\">\r\n            <x:Boolean x:Key=\"IsExpanded\">True</x:Boolean>\r\n          </scg:Dictionary>\r\n        </sap:WorkflowViewStateService.ViewState>\r\n      </sap2010:ViewStateData>\r\n      <sap2010:ViewStateData Id=\"New_Workflow_1\" sap:VirtualizedContainerService.HintSize=\"304,751\" />\r\n    </sap2010:ViewStateManager>\r\n  </sap2010:WorkflowViewState.ViewStateManager>\r\n</Activity>","culture":"en-DK","Parameters":[],"Serializable":false,"background":false,"Filename":"NewWorkflow.xaml","projectandname":"X2/detalleExecuteScript2","FilePath":"C:\\Users\\Allan\\Documents\\OpenRPA\\X2\\NewWorkflow.xaml","projectid":"6290c42282d133c035022ae0","name":"detalleExecuteScript2","_id":"88605a60-d836-4dfb-8408-fac7d42c8bc9","_type":"workflow","_modified":"2022-11-29T01:20:52.7700546+01:00","_modifiedby":"allan5","_modifiedbyid":"5ce94386320b9ce0bc2c3d07","_created":"0001-01-01T00:00:00","_createdby":"allan5","_createdbyid":"5ce94386320b9ce0bc2c3d07","_acl":[{"deny":null,"rights":65535,"_id":"5a1702fa245d9013697656fb","name":"admins"},{"deny":null,"rights":65535,"_id":"5ce94386320b9ce0bc2c3d07","name":"allan5"}],"_encrypt":null,"_version":7}
1 Like

Por lo que estuve leyendo por aqui fue por una actualización en la extensión de chrome.
Con su recomendación mi flujo ya funciona correctamente.

NOTA: El script JSON manda un error, por lo que tuve que leerlo y ver lo que se le agrego.

Para futuras consultas.
El flujo del ejemplo funcionando es la siguiente.
Mi ejemplo lo moví a InvokeCode ==> python puesto a que es lo que me interesa en este momento, sin embargo, con los otros lenguajes es algo similar.

Flujo.
1. jsEnNavegador.-

//Creating an object within the browser with JS “ExecuteScript”

objetoResult = {key1: “valor 1”, key2: “valor2”}

//The Chrome extension does not support sending objects, only simple types such as string, bool, and numbers.

//the output will be stored in @var objetoResult stored in Result of the element

JSON.stringify(objetoResult)

**2. código de invocación - InvokeCode .- **
#include json library
import json

#view original data
print(objetoResult)

#check data type, string , <class ‘str’>
print(type(objetoResult))

#convert string to object
json_object = json.loads(objetoResult)

#check new data type <class ‘dict’>
print(type(json_object))

#access first key name in dictionary
print("VALOR DE KEY ======== ^ ")
print(json_object[“key1”])

#[Output] valor 1

**GRACIAS @Allan_Zimmermann **