UiPath Automating clicks of a list sequentially on a webpage

半世苍凉 提交于 2021-01-29 16:11:02

问题


This is the website I am looking at.

In this website there is a list of companies where I can click into them:

  1. Click the name of the company
  2. Click the "Annual Report" button
  3. Click the "Annual Report & CG Report - 2018" link

There are 788 companies in this list and I wish to repeat this process for the whole list. Is this possible?

Currently I used Data Scraping -> Attach Browser url -> Extract Structured Data. After that I am stuck.


回答1:


For me that sounds pretty simple:

  1. go to overview
  2. download the list via data scraping
  3. for each on that list and surf to each of those urls
  4. on the url do the things you said, like clicking the Annual Report and then Annual Report & CG Report - 2018

So the usual structure of a UiPath process is this one:

This is the Main.xaml visual overview that works on your example:

And this is the Main.xaml code:

<Activity mc:Ignorable="sap sap2010" x:Class="Main" mva:VisualBasic.Settings="{x:Null}" sap:VirtualizedContainerService.HintSize="530,1075" sap2010:WorkflowViewState.IdRef="ActivityBuilder_1" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:ui="http://schemas.uipath.com/workflow/activities" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <TextExpression.NamespacesForImplementation>
    <scg:List x:TypeArguments="x:String" Capacity="22">
      <x:String>System.Activities</x:String>
      <x:String>System.Activities.Statements</x:String>
      <x:String>System.Activities.Expressions</x:String>
      <x:String>System.Activities.Validation</x:String>
      <x:String>System.Activities.XamlIntegration</x:String>
      <x:String>Microsoft.VisualBasic</x:String>
      <x:String>Microsoft.VisualBasic.Activities</x:String>
      <x:String>System</x:String>
      <x:String>System.Collections</x:String>
      <x:String>System.Collections.Generic</x:String>
      <x:String>System.Data</x:String>
      <x:String>System.Diagnostics</x:String>
      <x:String>System.Drawing</x:String>
      <x:String>System.IO</x:String>
      <x:String>System.Linq</x:String>
      <x:String>System.Net.Mail</x:String>
      <x:String>System.Xml</x:String>
      <x:String>System.Xml.Linq</x:String>
      <x:String>UiPath.Core</x:String>
      <x:String>UiPath.Core.Activities</x:String>
      <x:String>System.Windows.Markup</x:String>
      <x:String>UiPath.CV</x:String>
    </scg:List>
  </TextExpression.NamespacesForImplementation>
  <TextExpression.ReferencesForImplementation>
    <scg:List x:TypeArguments="AssemblyReference" Capacity="18">
      <AssemblyReference>System.Activities</AssemblyReference>
      <AssemblyReference>Microsoft.VisualBasic</AssemblyReference>
      <AssemblyReference>mscorlib</AssemblyReference>
      <AssemblyReference>System.Data</AssemblyReference>
      <AssemblyReference>System</AssemblyReference>
      <AssemblyReference>System.Drawing</AssemblyReference>
      <AssemblyReference>System.Core</AssemblyReference>
      <AssemblyReference>System.Xml</AssemblyReference>
      <AssemblyReference>System.Xml.Linq</AssemblyReference>
      <AssemblyReference>PresentationFramework</AssemblyReference>
      <AssemblyReference>WindowsBase</AssemblyReference>
      <AssemblyReference>PresentationCore</AssemblyReference>
      <AssemblyReference>System.Xaml</AssemblyReference>
      <AssemblyReference>UiPath.System.Activities</AssemblyReference>
      <AssemblyReference>UiPath.UiAutomation.Activities</AssemblyReference>
      <AssemblyReference>UiPath.CV</AssemblyReference>
      <AssemblyReference>System.ValueTuple</AssemblyReference>
      <AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>
    </scg:List>
  </TextExpression.ReferencesForImplementation>
  <Sequence sap:VirtualizedContainerService.HintSize="510,975" sap2010:WorkflowViewState.IdRef="Sequence_3">
    <Sequence.Variables>
      <Variable x:TypeArguments="sd:DataTable" Default="[New System.Data.DataTable]" Name="ExtractDataTable" />
      <Variable x:TypeArguments="ui:Browser" Name="Browser" />
    </Sequence.Variables>
    <sap:WorkflowViewStateService.ViewState>
      <scg:Dictionary x:TypeArguments="x:String, x:Object">
        <x:Boolean x:Key="IsExpanded">True</x:Boolean>
      </scg:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <ui:OpenBrowser CommunicationMethod="{x:Null}" Hidden="{x:Null}" NewSession="{x:Null}" Private="{x:Null}" BrowserType="Firefox" DisplayName="Open Browser" sap:VirtualizedContainerService.HintSize="468,351" sap2010:WorkflowViewState.IdRef="OpenBrowser_1" UiBrowser="[Browser]" Url="https://www.bursamalaysia.com/trade/trading_resources/listing_directory/main_market">
      <ui:OpenBrowser.Body>
        <ActivityAction x:TypeArguments="x:Object">
          <ActivityAction.Argument>
            <DelegateInArgument x:TypeArguments="x:Object" Name="ContextTarget" />
          </ActivityAction.Argument>
          <ui:BrowserScope Browser="{x:Null}" SearchScope="{x:Null}" TimeoutMS="{x:Null}" UiBrowser="{x:Null}" BrowserType="Firefox" DisplayName="Attach Browser" sap:VirtualizedContainerService.HintSize="434,252" sap2010:WorkflowViewState.IdRef="BrowserScope_2" InformativeScreenshot="49520eaf054f3a2d88e58aa9f0f1cdb7" Selector="&lt;html app='firefox.exe' title='Main Market' /&gt;">
            <ui:BrowserScope.Body>
              <ActivityAction x:TypeArguments="x:Object">
                <ActivityAction.Argument>
                  <DelegateInArgument x:TypeArguments="x:Object" Name="ContextTarget" />
                </ActivityAction.Argument>
                <ui:ExtractData DelayBetweenPagesMS="{x:Null}" ContinueOnError="True" DataTable="[ExtractDataTable]" DisplayName="Extract Structured Data" ExtractMetadata="&lt;extract&gt;&lt;column exact='1' name='Name' attr='text' name2='URL' attr2='href'&gt;&lt;webctrl tag='tr'/&gt;&lt;webctrl tag='td' class=' text-left position-relative'/&gt;&lt;webctrl tag='a' class='company-announcement-link' idx='1'/&gt;&lt;/column&gt;&lt;/extract&gt;" sap:VirtualizedContainerService.HintSize="334,106" sap2010:WorkflowViewState.IdRef="ExtractData_2" MaxNumberOfResults="100" NextLinkSelector="&lt;webctrl parentid='DataTables_Table_0_next' tag='A' /&gt;" SimulateClick="True">
                  <ui:ExtractData.Target>
                    <ui:Target ClippingRegion="{x:Null}" Element="{x:Null}" InformativeScreenshot="c9106f042e4e67a92a010ed284896366" Selector="&lt;webctrl parentid='DataTables_Table_0' tag='TBODY' /&gt;" WaitForReady="COMPLETE">
                      <ui:Target.TimeoutMS>
                        <InArgument x:TypeArguments="x:Int32" />
                      </ui:Target.TimeoutMS>
                    </ui:Target>
                  </ui:ExtractData.Target>
                </ui:ExtractData>
              </ActivityAction>
            </ui:BrowserScope.Body>
          </ui:BrowserScope>
        </ActivityAction>
      </ui:OpenBrowser.Body>
    </ui:OpenBrowser>
    <ui:ForEachRow CurrentIndex="{x:Null}" DataTable="[ExtractDataTable]" DisplayName="For Each Row" sap:VirtualizedContainerService.HintSize="468,492" sap2010:WorkflowViewState.IdRef="ForEachRow_1">
      <ui:ForEachRow.Body>
        <ActivityAction x:TypeArguments="sd:DataRow">
          <ActivityAction.Argument>
            <DelegateInArgument x:TypeArguments="sd:DataRow" Name="row" />
          </ActivityAction.Argument>
          <Sequence DisplayName="Body" sap:VirtualizedContainerService.HintSize="376,344" sap2010:WorkflowViewState.IdRef="Sequence_7">
            <sap:WorkflowViewStateService.ViewState>
              <scg:Dictionary x:TypeArguments="x:String, x:Object">
                <x:Boolean x:Key="IsExpanded">True</x:Boolean>
              </scg:Dictionary>
            </sap:WorkflowViewStateService.ViewState>
            <ui:NavigateTo Browser="[Browser]" DisplayName="Navigate To" sap:VirtualizedContainerService.HintSize="334,59" sap2010:WorkflowViewState.IdRef="NavigateTo_1" Url="[&quot;https://www.bursamalaysia.com&quot; + row(&quot;Url&quot;).ToString]" />
            <Delay Duration="00:00:05" sap:VirtualizedContainerService.HintSize="334,22" sap2010:WorkflowViewState.IdRef="Delay_1" />
            <ui:LogMessage DisplayName="Log Message" sap:VirtualizedContainerService.HintSize="334,91" sap2010:WorkflowViewState.IdRef="LogMessage_3" Level="Info" Message="[&quot;Here you do all the stuff like Click Annual Report...&quot;]" />
          </Sequence>
        </ActivityAction>
      </ui:ForEachRow.Body>
    </ui:ForEachRow>
  </Sequence>
</Activity>


来源:https://stackoverflow.com/questions/61380604/uipath-automating-clicks-of-a-list-sequentially-on-a-webpage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!