UiPath Activities

The UiPath Activities Guide

Automate Web Page Navigation

The example below explains how to automate the navigation on a web page by using the Extract Structured Data and Get Attribute activities. You can find these activities in the UiPath.UIAutomation.Activities package.

This is how the automation process can be built:

  1. Open Studio and create a new Process.
  2. Drag a Sequence container in the Workflow Designer.
  3. Place an Open Browser activity inside the Sequence container.
    • Add the value "https://www.youtube.com/user/UiPath/videos" in the Url field.
    • In the Properties panel, select the desired browser from the BrowserType drop-down list. For this example, Internet Explorer is used.
    • Select the check box for the NewSession option is selected. This starts a new session of the selected browser.
  4. Select the Do container found inside the Open Browser activity and create the following variables:
Variable Name
Variable Type
Default Value

ExtractDataTable

System.Data.DataTable

-

ViewType

String

-

MaxViews

Int32

0

MaxViewVideoName

String

-

CurrentViews

Int32

-

MaxViewsLink

String

-

  1. Place a Get Attribute activity inside the Do container.
    • Inside the activity, click the Indicate element inside browser option. Select the menu button like in the following GIF:
      1
    • In the Properties panel, add the value "innertext" in the Attribute field.
    • Select the INTERACTIVE option from the WaitForReady drop-down list.
    • Add the variable ViewType in the Result field.
  2. Drag an If container below the Get Attribute activity.
    • Insert the expression ViewType.StartsWith("List") in the Condition field.
  3. Place a Sequence activity inside the Then container of the If activity.
  4. Drag a Click activity inside the Sequence container.
    • Inside the activity, click the Indicate element inside browser option. Select the menu button like in the following GIF:
      2
    • In the Properties panel, select the check box for the SimulateClick option. This simulates, in the background, the type by using the technology of the target application.
  5. Drag another Click activity and place it below the first one.
    • Inside the activity, click the Indicate element inside browser option. Select the menu button like in the following GIF:
      3
    • In the Properties panel, select the check box for the SimulateClick option. This simulates, in the background, the type by using the technology of the target application.
  6. Place a Delay activity below the If activity and set its duration to 5 seconds.
  7. Drag an Extract Structured Data activity below the Delay activity.
    • Inside the activity, click the Indicate element inside browser option. Select the menu button like in the following GIF:
      4
    • In the Properties panel, add the value True in the ContinueOnError field.
    • Add the following xml string in the ExtractMetadata field.
      <extract>
      <row exact='1'>
      <webctrl tag='li' class='channels-content-item yt-shelf-grid-item' />
      <webctrl tag='div' class='yt-lockup clearfix yt-lockup-video yt-lockup-grid' idx='1' />
      <webctrl tag='div' class='yt-lockup-dismissable' idx='1' />
      <webctrl tag='div' class='yt-lockup-content' idx='1' />
      </row>
      <column name='VideoName' attr='text' exact='1' attr2='href' name2='VideoLink'>
      <webctrl tag='li' class='channels-content-item yt-shelf-grid-item' />
      <webctrl tag='div' class='yt-lockup clearfix yt-lockup-video yt-lockup-grid' idx='1' />
      <webctrl tag='div' class='yt-lockup-dismissable' idx='1' />
      <webctrl tag='div' class='yt-lockup-content' idx='1' />
      <webctrl tag='h3' class='yt-lockup-title ' idx='1' />
      <webctrl tag='a' class='yt-uix-sessionlink yt-uix-tile-link  spf-link  yt-ui-ellipsis yt-ui-ellipsis-2' idx='1' />
      </column>
      <column name='Views' attr='text' exact='1'>
      <webctrl tag='li' class='channels-content-item yt-shelf-grid-item' />
      <webctrl tag='div' class='yt-lockup clearfix yt-lockup-video yt-lockup-grid' idx='1' />
      <webctrl tag='div' class='yt-lockup-dismissable' idx='1' />
      <webctrl tag='div' class='yt-lockup-content' idx='1' />
      <webctrl tag='div' class='yt-lockup-meta' idx='1' />
      <webctrl tag='ul' class='yt-lockup-meta-info' idx='1' />
      <webctrl tag='li' idx='1' />
      </column></extract>
      
    • Select the COMPLETE option from the WaitForReady drop-down list.
    • Add the variable ExtractDatatable in the DataTable field.
  8. Drag a For Each Row activity below the Extract Structured Data activity.
    • Add the variable ExtractDataTable in the DataTable field.
  9. Drag an Assign activity inside the Body of the For Each Row activity.
    • Add the variable CurrentViews in the To field.
    • Add the expression Cint(row("Views").ToString.Split(" "c).First) in the Values field.
  10. Drag an If activity below the Assign activity.
    • Add the expression CurrentViews > MaxViews in the Condition field.
  11. Drag an Assign activity inside the Sequence container.
    • Add the variable MaxViewsLink in the To field.
    • Add the expression row("VideoLink").ToString in the Value field.
  12. Drag another Assign activity below the first one.
    • Add the variable MaxViews in the To field.
    • Add the variable CurrentViews in the Value field.
  13. Place another Assign activity below the previous one.
    • Add the variable MaxViewVideoName in the To field.
    • Add the variable row("VideoName").ToString in the Value field.
  14. Drag a Navigate To activity below the For Each Row activity.
    • Add the expression "www.youtube.com" + MaxViewsLink in the Url field.
  15. Add a Write Line activity below the Navigate To activity.
    • Add the expression "You are now watching the video with max views: " + MaxViewVideoName in the Text field.
  16. Run the process. A Youtube page with the UiPath channel is open and the most-watched video starts playing.

Updated about a month ago


Automate Web Page Navigation


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.