Sample – Supply Chain Management

Overview

This is a sample of supply chain solution with Clicknium web automation. Here is the details:

Here are the details: based on a PO number, the solution finds and captures data from another “Purchase Order Tracking” web app and looks up the state of the agent from an Excel file to finally fill the data to the PO management web portal.

The manual steps are as follows:

Step1. Download excel file from PO management portal.
Step2. Copy PO number from web portal.
Step3. Login and query PO data based on PO number.
Step4. Look up the agent information from Excel based on the state.
Step5. Fill the PO data into PO management portal.

Practical Walkthrough

To run this sample, follow these steps:

git clone https://github.com/clicknium/clicknium-samples.git
  • Open the folder ‘SupplyChainManagement’ in Visual Studio Code
  • Install the dependent packages through “pip

requests” is used to download the CSV file and “pandas is used to read CSV file.

pip install requests
pip install pandas
  • Open app.py in Visual Studio Code.
  • Press “F5” to debug the sample or press CTRL+F5 to run sample.

You will see the result as below.

The Purpose of The Sample

  • Open PO management portal to capture the URL of the Excel fiel to be downloaded.
  • Download the excel file with “requests “module
  • Load data from the Excel file with “pandas” module
tab = cc.edge.open("https://developer.automationanywhere.com/challenges/automationanywherelabs-supplychainmanagement.html")
url = tab.find_element(locator.supplychainmanagement.developer.a_downloadagentterritoryspreadsheet).get_property("href")
excelFile = requests.get(url)
temp_file = os.path.join(os.getcwd(), 'test.xlsx')
open(temp_file, 'wb').write(excelFile.content)
data = pd.read_excel(temp_file,header=1)
  • open Purchase Order Tracking web app and login
proc_tab = tab.browser.new_tab("https://developer.automationanywhere.com/challenges/AutomationAnywhereLabs-POTrackingLogin.html")
proc_tab.find_element(locator.supplychainmanagement.developer.email_inputemail).set_text('username')
proc_tab.find_element(locator.supplychainmanagement.developer.password_inputpassword).set_text('password')
proc_tab.find_element(locator.supplychainmanagement.developer.button_signin).click()

After the browser is opened, it will return to the edge tab/page.

With Clicknium web automaton, find all elements for each PO item, such as PO number, ship date, order total and assigned agent.

po_elements = tab.find_elements(locator.supplychainmanagement.developer.text_ponumber)
date_elements = tab.find_elements(locator.supplychainmanagement.developer.text_shipdate)
total_elements = tab.find_elements(locator.supplychainmanagement.developer.text_ordertotal)
agent_elements = tab.find_elements(locator.supplychainmanagement.developer.select_agent)
count = len(po_elements)

Here, we leverage Clicknium’s “find_elements” API to find all similar elements. For example, for element’s locator of the “PO number“:

When the value of ID is set to “PONumber*“, it will match all elements with ID starting with “PONumber“.

  • The solution then iterates each PO number element, captures the PO number and query the data from “Purchase Order Tracking” web app to fill the data in web portal by submitting finally.
for i in range(count):
po = po_elements[i].get_text()
proc_tab.find_element(locator.supplychainmanagement.developer.search).set_text(po)
state = proc_tab.find_element(locator.supplychainmanagement.developer.td, {"column":5}).get_text()
ship_date = proc_tab.find_element(locator.supplychainmanagement.developer.td, {"column":'7'}).get_text()
total = proc_tab.find_element(locator.supplychainmanagement.developer.td, {"column":'8'}).get_text()
for idx,item in data.iterrows():
if item[0] == state:
agent = item[1]
break
date_elements[i].set_text(ship_date)
total_elements[i].set_text(total[1:].strip())
agent_elements[i].select_item(agent)

tab.find_element(locator.supplychainmanagement.developer.button_submitbutton).click()


To extract the “text of state“, “ship_date“, and “total” from a webpage, we can use  parametric locator . This allows us to specify the parameter value, so that one locator can be used to locate several elements.

Locator

Locator is a identifier of UI element,which can be recorded and edited with clicknium vs code extension.

More samples

You can refer to more automation samples and solutions in clicknium github samples.
Send email to us or Join Slack.

What are your feelings