Create Order Process
Open the robot order website
To get things started, you need to implement a function for opening the robot order website. Here's a draft for the function. You need to add the implementation (calling functions to accomplish things):
Visual Studio Code: You can place the function definitions either before or after the
@task
annotated function. The order does not matter.
Hints
- You need a library that knows how to work with a web browser.
- We recommend using the browser module of the robocorp library for this course.
- After importing the library, call the function for opening the browser. You might need to provide the URL of the robot order website!
When you get the robot order website to open in a web browser, you can proceed to the next step!
Download the orders file, read it as a table, and return the result
Hints
- The orders CSV file is here: https://robotsparebinindustries.com/orders.csv
- You need another module from the robocorp library for downloading things.
- You want to overwrite the downloaded file if it exists to be able to run your robot over and over again. There is an argument for telling that overwriting is ok!
- There is an RPA Framework library for reading CSV files into
tables
that can then be looped in a robot script. Sometimes, theReadme
of the library contains all the information we need 😉.All RPA Framework libraries can be used with Python as well. Check out the examples from each library to get a better idea.
- You need your custom
get_orders()
function to return the result. Check out returning things from a function. - Learn about assigning variables to assign the returned orders to a variable.
You can check if your code works from the log after you run your robot.
Loop the orders
You need to complete the ordering process for each of the orders.
Hints
- You need to use a for loop.
- For now, you can just log each order row inside the loop.
Give up all your constitutional rights!
Time to get rid of that annoying modal that pops up when you open the robot order website.
Let's implement the close_annoying_modal()
function.
Hints
- You have already imported the library you need.
- Functions that click on things might prove useful here.
- The "click on stuff" function needs a locator so that they know what to click on. Locators are the bread and butter of automating web applications. It is good to spend some time reading about those.
- You can use the browser inspector tools to find the elements to click on.
- You can target HTML elements either with CSS type, class, ID, or attribute selectors or XPath expressions, or a combination of CSS, XPath, and text selectors.
Fill the form
Time to tackle the fill_the_form()
function. This example function takes an argument.
Hints
- Use the order row that you got from the loop you built as the argument for this form filler function.
- If the name of the variable you got from the loop is, for example,
row
, you can access the value of theOrder number
column like this:row['Order number']
. - You need functions for selecting things and inputting text. You have a library you need already imported!
- The input element for the leg number is slightly annoying. It does have an
id
attribute, but the value seems to change all the time! 🤬 Can you think of a way of targeting that element? There are no "correct" answers here, just many options!
Preview the robot
To robotically get the image of the robot, the robot needs to preview the robot (Yo Dawg!).
Hints
- Click on stuff. Business as usual!
Submit the order
This one is a bit trickier case. Sometimes the submit fails. We really want the robot to complete the orders even when there are occasional errors on submit. How do we do that? 🤔
Hints
- When it fails, an error message is displayed on the screen.
- If there is an error, you just have to click order again and hope it works.