How to read Excel file, loop through rows, and perform AppRobotic Actions for each row in Python?

How to read Excel file, loop through rows, and perform AppRobotic Actions for each row in Python?

QA 0

How to read Excel file, loop through rows, and perform certain AppRobotic Action steps for each row in Python?

Let’s say that we have 2 URLs in an Excel sheet (Sheet1). Cell A1 has a URL such as google.com and cell A2 also has a URL such as google.com. Below, we open a web browser, loop through all rows in the Excel file, and perform macro steps to search Google.

Python Code:

import win32com.client
x = win32com.client.Dispatch("AppRobotic.API")
import sys

# loop through all Excel Sheet rows, print the result to Log Printout, and perform Action steps

# Load Excel file
x.ExcelInputFileLoad(r'C:\\Users\\Administrator\\Desktop\\test.xlsx','Sheet1')

# move to the next unread row
isEOF = x.ExcelInputFileGoToNextRow()

if isEOF = "EOF":
x.Print("Reached End of File, all Excel Sheet rows have been processed.")
# exit current bot run
sys.exit()

# read URL in current Row, Column 1 in Text format, for example if URL is https://www.google.com
url = x.ExcelInputFileRead(1, 'Text')

# send cell value to AppRobotic Printer for logging
x.Print(url)

# open with Edge web browser
# same as x.OpenURLEdge("https://www.google.com")
x.OpenURLEdge(url)

# wait a bit for page to open
x.Wait(3000)
# use UI Item Explorer to get X,Y coordinates of Search box
x.MoveCursor(438, 435)
# click inside Search box
x.MouseLeftClick

x.Type("AppRobotic")
x.Type("{ENTER}")