How to use Export UI Tree activity to output to a variable

Greetings:

I am able to extract to a file, but, the Activity indicates that if the path is left blank, it will be exported to the “ExportedString out argument”.

Where can this be found so the I can access this in later code? I’d like to save this to a variable, as it seems to be the ONLY way I can find the returns the data I need from a web page.

Regards,
Scott

1 Like

Hi,

It seems we cannot use ExportedString property although ExportUiTree has the property as out type argument internally as the following.

image

Perhaps you should raise a (bug?) report regarding it.

BTW, I suppose we might be able to use FindChildern atctivity instead of ExportUiTree.
Can you elaborate your requirement?

Regards,

Thank you. I tried FindChildren - but I couldn’t get the actual text of the information on the page - or at least I wasn’t sure how to do it. I think the text area I need the dat from is dynamically created (i.e. only part of it loads, until I scroll on the element). No matter what I do, I cannot get all the text from this box. If I use the Get Text activity, only the first couple of lines are retrieved. If I use Click on element, then Keyboard Shortcuts for CTRL+A and CTRL+C, then retrieve from clipboard, only the first few lines - IF I’m lucky. Mostly, it can’t find the element (I have multiple screens, and it keeps highlighting some phantom element on another screen that doesn’t even have a browser). So far, this has been the only activity that actually consistently gets the data I need - but I just need it as a variable - not a file. I’m pretty surprised at how hard it is just to get the raw web page information. I don’t remember it being this difficult in the past - before being required to use the Use Application/Browser scope. Really seems to have taken control away with this method.

Hi,

As a workaround, we can output the string to a file, then read it using ReadTextFile activity. (This might be inefficient…)

image

Regards,

1 Like

@scott_zielinski

Did you try with get attribute and in erhtml?

Cheers

Yeah. Any of those types of Activities only extract what is visible on the screen. I.E. If the box displays 20 lines, it will extract 21, even though there are 51 in total if you scroll down. Its really bizarre. I’ve never encountered such a troublesome Element/Selector before. I just don’t understand what the deal is with this box.

As a workaround, we can output the string to a file, then read it using ReadTextFile activity. (This might be inefficient…)

Yeah, that is my workaround so far - I really don’t want to do that, as this bot will be used by not just me, but several others on the team.

@scott_zielinski

Try getting the element then get the anscentor of it and get the values from that…may be innerhtml will get all details than inner text and then we cna try manipulations

Cheers

1 Like

AH! You mean innerhtml; I tried that and I believe that worked! Thank you!

1 Like

I spoke too soon. I happened to have scrolled down. When I scrolled back up; I encounter the same issue - only the visible lines are extracted. :confused:

@scott_zielinski

Even with the parent element its happening the same way?

May be you can try mouse scroll before extract or can do a page down and then extract?

Cheers

Maybe I’m missing something, but when I Get Ancestor, I don’t get anything from the text box.

May be you can try mouse scroll before extract or can do a page down and then extract?

If I scroll down, I only get the bottom part. I.E. Only what is physically visible gets extracted. The only exception is Export UI Tree - but that doesn’t go to a variable, only a file.

Nevermind. I can’t even get it using Export UI Tree. Somehow I thought that worked, but even that its the same thing - only what’s visible extracts. I’m at a total loss.

Manually if I CTRL+A CTRL+C to copy and paste, it works. When I try to do that in code, it never does. Whether using Get Text, or Copy Selected Text or whatever it is - for some reason UI Path cannot access the non visible information. Its so bizarre.

For anyones future reference, this is a weird activity because for some reason they have set the ExportedString OutArgument to have the [Browsable(false)] tag. This stops the property from being displayed in the Properties window and since its not made available via the activity card its basically made very difficult to access.

Should you need to do it then you can by directly editing the xaml the activity is in.
For example if you have the following xaml code for the activity.

    <ui:ExportUiTree DestinationFile="{x:Null}" ExportedString="{x:Null}" Filter="{x:Null}" OperationTimeoutMS="{x:Null}" DisplayName="Export UI Tree 'LI'" Format="XML" sap:VirtualizedContainerService.HintSize="338,245" sap2010:WorkflowViewState.IdRef="ExportUiTree_1" IncludeScreenshots="False" Overwrite="False" Priority="Performance" UiFramework="Default">	  
      <ui:ExportUiTree.Target>
        <ui:Target ClippingRegion="{x:Null}" Element="{x:Null}" Id="88dd9e49-fb27-4ae0-b85b-8bda3ab90d7d" InformativeScreenshot="db971900a9e0541a53e26f2e436d5a94" Selector="&lt;html app='chrome.exe' title='LIVE | Home' /&gt;&lt;webctrl css-selector='body&amp;gt;table&amp;gt;tbody&amp;gt;tr&amp;gt;td&amp;gt;table&amp;gt;tbody&amp;gt;tr&amp;gt;td&amp;gt;div&amp;gt;ul&amp;gt;li' idx='3' tag='LI' /&gt;">
          <ui:Target.TimeoutMS>
            <InArgument x:TypeArguments="x:Int32" />
          </ui:Target.TimeoutMS>
          <ui:Target.WaitForReady>
            <InArgument x:TypeArguments="ui:WaitForReady" />
          </ui:Target.WaitForReady>
        </ui:Target>
      </ui:ExportUiTree.Target>
    </ui:ExportUiTree>

You can see here the ExportedString property is available and set as null. You can edit it and set it to this.

<ui:ExportUiTree DestinationFile="{x:Null}" Filter="{x:Null}" OperationTimeoutMS="{x:Null}" DisplayName="Export UI Tree 'LI'" Format="XML" sap:VirtualizedContainerService.HintSize="338,245" sap2010:WorkflowViewState.IdRef="ExportUiTree_1" IncludeScreenshots="False" Overwrite="False" Priority="Performance" UiFramework="Default">
      <ui:ExportUiTree.ExportedString>
        <OutArgument x:TypeArguments="x:String">
          <mca:CSharpReference x:TypeArguments="x:String" sap2010:WorkflowViewState.IdRef="CSharpReference`1_1">test</mca:CSharpReference>
        </OutArgument>
      </ui:ExportUiTree.ExportedString>
      <ui:ExportUiTree.Target>
        <ui:Target ClippingRegion="{x:Null}" Element="{x:Null}" Id="88dd9e49-fb27-4ae0-b85b-8bda3ab90d7d" InformativeScreenshot="db971900a9e0541a53e26f2e436d5a94" Selector="&lt;html app='chrome.exe' title='LIVE | Home' /&gt;&lt;webctrl css-selector='body&amp;gt;table&amp;gt;tbody&amp;gt;tr&amp;gt;td&amp;gt;table&amp;gt;tbody&amp;gt;tr&amp;gt;td&amp;gt;div&amp;gt;ul&amp;gt;li' idx='3' tag='LI' /&gt;">
          <ui:Target.TimeoutMS>
            <InArgument x:TypeArguments="x:Int32" />
          </ui:Target.TimeoutMS>
          <ui:Target.WaitForReady>
            <InArgument x:TypeArguments="ui:WaitForReady" />
          </ui:Target.WaitForReady>
        </ui:Target>
      </ui:ExportUiTree.Target>
    </ui:ExportUiTree>

In this one you’ll see the ExportedString attribute is removed and a new node is added to specify that it is outputted to a variable called ‘test’. (Please note this is using a C# project, it should still work as is in a VB.Net project but you can also adjust the node to use the VB syntax.

This now works when you run the workflow to output the value.
I really have no clue why browsable was set to false. Seems like a bug?