Here's a simple sample program in UiPath that automates the process of logging into a website and retrieving data. This example will demonstrate how to log into a mock website, navigate to a specific section, and extract data from a table.
Scenario:
Website: A mock e-commerce site where you log in and extract the list of products.
Actions: Open browser, log in, navigate to the products page, and extract product names and prices.
Steps:
Open UiPath Studio and create a new project.
Add Dependencies: Ensure that the necessary packages (like UiPath.Excel.Activities and UiPath.WebAPI.Activities) are installed.
Step-by-Step Guide:
1. Open Browser and Navigate to Login Page
Activity: Use Open Browser
Properties:
BrowserType: Chrome (or your preferred browser)
URL: "https://www.mockwebsite.com/login"
2. Log In to the Website
Activity: Use Type Into to enter the username and password.
Selector: Use UI Explorer to find the correct selectors for the username and password fields.
Text: "your_username" and "your_password"
Use another Type Into for the password field, and then use Click on the login button.
plaintext
<webctrl id='username' tag='INPUT' />
<webctrl id='password' tag='INPUT' />
<webctrl id='loginButton' tag='BUTTON' />
Activity: Click
Selector: The selector for the "Login" button.
3. Navigate to the Products Page
Activity: Use Click
Selector: The selector for the "Products" link or button in the navigation menu.
plaintext
<webctrl tag='A' aaname='Products' />
4. Extract Data from the Table
Activity: Use Data Scraping
Follow the wizard to select the product table on the page.
Column Names: Product Name, Price
Configure the wizard to scrape all rows from the table.
5. Save Data to Excel
Activity: Use Write Range (from UiPath.Excel.Activities)
Properties:
DataTable: The DataTable variable that holds the scraped data.
FilePath: "C:pathtoyourfile.xlsx"
SheetName: "Products"
6. Close the Browser
Activity: Use Close Tab or Close Application
Final Workflow
Your final workflow should look something like this:
Open Browser → Type Into (Username) → Type Into (Password) → Click (Login) → Click (Products Page) → Data Scraping Wizard → Write Range → Close Tab
Running the Program
Publish or Run: You can run the workflow directly from UiPath Studio or publish it as a package to run via the UiPath Robot.