UiPath Activities

The UiPath Activities Guide

HTML pages: Extract and Manipulate Information

The example below explains how to automate the action of browsing a web page, extract information and use it for creating a new, local html page. It presents activities such as Type Into, Click, Get Text, and Open Browser. 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. Open Internet Explorer and navigate to www.goodreads.com.
  3. Drag a Flowchart container in the Workflow Designer.
    • Create the following variables:
Variable Name
Variable Type
Default Value

bookFound

String

-

bookName

GenericValue

-

  1. Drag an Input Dialog activity inside the Flowchart container and connect it to the Start node.
    • Double-click the activity in order to open it.
    • Add the expression "Book Name:" in the Title field.
    • Add the expression "Enter the name of a book you read:" in the Label field.
    • In the Properties panel, add the variable bookName in the Result field.
    • The activity should look like in the following screenshot:
  1. Return to the Flowchart screen.

  1. Drag a Sequence container and connect it to the Input Dialog activity. This is used for creating a new .html file.
    • Create the following variable:
Variable Name
Variable Type
Default Value

fileExists

Boolean

-

  1. Double-click the Sequence container to open it and drag a Path Exists activity inside it.
    • Select the File option from the Path Type drop-down list.
    • Add the expression "books.html" in the Path field.
    • In the Properties panel, add the variable fileExists in the Exists field.
  2. Drag an If activity below the Path Exists activity.
    • Add the variable fileExists in the Condition field.
  3. Place a Write Text File activity in the Else field.
    • Add the expression "books.html" in the FileName field.
    • Add the code below in the Text field.
      <html>
      <head>
      <title>Books</title>
      </head>
      <body>
      </body>
      </html>
      
    • The activity should look like in the following screenshot:
  1. Return to the Flowchart screen.

  1. Drag an Open Browser activity and connect it to the Sequence container.
    • Double-click the activity in order to open it.
    • In the Properties panel, select the IE option from the BrowserType drop-down list.
    • Add the expression "https://www.goodreads.com/search" in the Url field. This opens the specified website.
    • Select the check box for the NewSession option. This opens a new session of the selected browser.
  2. Select the Do container from inside the Open Browser activity and create the following variable:
Variable Name
Variable Type
Default Value

noResults

GenericValue

-

  1. Drag a Type Into activity inside the Do sequence.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the desired application. The GIF below shows all the steps you need to follow:
      1
    • Add the variable bookName in the Text field.
  2. Place a Click activity below the Type Into activity.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the desired application. The GIF below shows all the steps you need to follow:
      2
    • In the Properties panel, add the value 1000 in the DelayBefore field. A delay of one second happens before performing any operation.
  3. Drag a Get Text activity below the Click 'INPUT' activity.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the desired application. The GIF below shows all the steps you need to follow:
      3
    • In the Properties panel, add the variable noResults in the Value field.
  4. Drag an If activity below the Get Text 'H3' activity.
    • Add the expression noResults.toLower.Trim.Contains("no results") in the Condition field.
  5. Place a Sequence container inside the Then field.
  6. Drag a Message Box activity inside the Sequence container.
    • Add the message "Book not found. Please search another one." in the Text field. If no result is available, then this message is displayed.
  7. Drag a Close Tab activity below the Message Box activity. This closes the tab open in the web browser.
  8. Place a Sequence container inside the Else field.
  9. Drag a Get Text activity inside the Sequence container.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the desired application. The GIF below shows all the steps you need to follow:
      5
    • In the Properties panel, add the variable bookFound in the Value field.
  10. Drag an If activity below the Get Text 'SPAN' activity.
    • Add the expression bookFound.ToLower.Trim.Contains(bookName.ToLower.Trim) in the Condition field.
  11. Drag a Sequence container inside the Then field and create the following variable:
Variable Name
Variable Type
Default Value

realName

String

-

  1. Place a Click activity inside the Sequence container.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the book's title. The GIF below shows all the steps you need to follow:
      5
  2. Drag another Sequence container below the Click 'SPAN' activity, name it Get book Details and create the following variables:
Variable Name
Variable Type
Default Value

description

GenericValue

-

author

GenericValue

-

booksContent

String

-

alreadyExists

Boolean

-

  1. Drag a Get Text activity inside the Sequence container.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the book's title. The GIF below shows all the steps you need to follow:
      6
    • In the Properties panel, add the variable realName in the Value field.
  2. Place an Assign activity below the Get Text 'H1 bookTitle' activity.
    • Add the variable realName in the To field.
    • Add the expression realName.Replace(":","").Replace("'","").Trim in the Value field.
  3. Add a Path Exists activity below the Assign activity.
    • Select the File option from the PathType drop-down list.
    • Add the expression Environment.CurrentDirectory+"\"+realName+".jpg" in the Path field.
    • In the Properties panel, add the variable alreadyExists in the Exists field.
  4. Drag another If activity below the Path Exists activity.
    • Add the variable alreadyExists in the Condition field.
  5. Place a Sequence container inside the Then field.
  6. Drag a Message Box activity inside the Sequence container.
    • Add the message "Book already added." in the Text field.
    • In the Properties panel, select the Ok option from the Buttons drop-down menu.
  7. Drag a Close Tab activity below the Message Box activity. This closes the tab opened in the web browser.
  8. Place a Sequence container inside the Else field.
  9. Place another Sequence container inside the previous one.
  10. Drag a Get Text activity inside the Sequence container.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the book's title. The GIF below shows all the steps you need to follow:
      4
    • In the Properties panel, add the variable description in the Value field.
  11. Drag a Get Text activity below the getDescription activity.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the book's title. The GIF below shows all the steps you need to follow:
      7
    • In the Properties panel, add the variable author in the Value field.
  12. Drag a Click activity below the getAuthor activity.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the book's title. The GIF below shows all the steps you need to follow:
      7
    • In the Properties panel, select the BTN_RIGHT option from the MouseButton drop-down list. This action right clicks on the image and a menu is displayed.
    • Add the value 89 in the OffsetX field.
    • Add the value 22 in the OffsetY field.
    • Select the TopLeft option from the Position drop-down list.
  13. Drag a Delay activity below the Click 'IMG coverImage' activity.
    • In the Properties panel, add the value 00:00:02 in the Duration field. This provides a two-second delay.
  14. Place a new Click activity below the Delay activity.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the book's title. The GIF below shows all the steps you need to follow:
      8
  15. Drag a Type Into activity below the Click 'menu item' activity.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the book's title. The GIF below shows all the steps you need to follow:
      9
  16. In the Properties panel, add the expression Environment.CurrentDirectory+"\"+realName+".jpg" in the Text field.
  17. Place a Click activity below the Type Into 'Edit' activity.
    • Inside the activity, click the Indicate element inside browser option. Now you can select the book's title. The GIF below shows all the steps you need to follow:
      10
  18. Drag a Write Text File activity underneath the Click 'Button' activity.
    • Add the expression realName+".html" in the FileName field.
    • Add the below code in the Text field.
"<html>
  <head>
    <title>"+realName+"</title>
  </head>
  <body>
    <a href='books.html'>BACK</a>
    <h1>"+realName+"</h1>
    <h2>by "+author+"</h2>
      <img src='"+realName+".jpg'>
    <h3>"+description+"</h3>
   </body>
 </html>"
  1. Place a Read Text File activity below the Write Text File activity.
    • Add the expression "books.html" in the FileName field.
    • Add the variable booksContent in the Content field.
  2. Drag another Write Text File activity underneath the Read Text File activity.
    • Add the expression "books.html" in the FileName field.
    • Add string booksContent.Replace("</body></html>","<h1><a href='"+realName+".html'>"+realName+"</h1></body></html>") in the Text field.
  3. Add a Close Tab activity below the Write Text File activity.
  4. Drag an Open Browser activity below the Close Tab activity. This opens the newly created .html file.
    • Select the IE option from the BrowserType drop-down list.
    • Add the expression "file:\\\"+Environment.CurrentDirectory+"\books.html" in the Url field.
  5. Return to the initial If activity and add a Sequence container inside the Else field.
  6. Drag a Message Box activity inside the Sequence container.
    • Add the expression "Book not found. Please check the name and try again" in the Text field.
  7. Add a Close Tab activity below the Write Text File activity.
  8. Run the workflow. The automation process requests a book name, searches it on www.goodreads.com, retrieves information about the book, creates a basic .html page, and populates it with the retrieved information.

Updated about a month ago


HTML pages: Extract and Manipulate Information


Suggested Edits are limited on API Reference Pages

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