robocorp / rpaframework

Collection of open-source libraries and tools for Robotic Process Automation (RPA), designed to be used with both Robot Framework and Python
https://www.rpaframework.org/
Apache License 2.0
1.15k stars 222 forks source link

Improvements to `RPA.Excel.Application` and `RPA.Browser.Selenium` libraries #1191

Closed mikahanninen closed 4 months ago

mikahanninen commented 4 months ago

Example on opening URLs with RPA.Excel.Application library

# Open Robocorp course SalesData workbook
EXCEL.open_workbook("https://robotsparebinindustries.com/SalesData.xlsx")
results = lib.find("Name", search_type="values")
# Open workbook from Sharepoint
sharepoint_file_url = f"https://{SHAREPOINT_DOMAIN}.sharepoint.com/{SHAREPOINT_FOLDER_STRUCTURE}/test.xlsx"
EXCEL.open_workbook(sharepoint_file_url)

Example on formatting cells with RPA.Excel.Application library.

data_headers_range = EXCEL.get_range("data!A1:D1")
for dh_cell_range in data_headers_range:
    print(f"dh_cell_range .Address = {dh_cell_range.Address}")
    dh_cell_range.Font.Size = 32
    dh_cell_range.Font.Bold = True
    dh_cell_range.Interior.Color = rgb_to_excel_color(115, 147, 179)
data_headers_range.Columns.AutoFit()

Example on find improvements with RPA.Excel.Application library.

results = lib.find(
    "INVENTORY",
    search_type="values",
    exact=True,
    match_case=True,
)
if not results:
    print("Did not find INVENTORY cell")
else:
    search_after = results[0]
    print(f"INVENTORY CELL ADDR = {search_after.Address} VALUE = {search_after.Value}")
    results = lib.find(
        "QUANTITY",
        search_type="values",
        search_after=search_after,
        exact=True,
        match_case=True,
    )
    if not results:
        print("Did not find QUANTITY cell")
    for r in results:
        print(f"QUANTITY ADDR = {r.Address} VALUE = {r.Value}")

Example on browser workaround with RPA.Browser.Selenium library.


browser.open_available_browser(
    'https://robocorp.com/portal',
    browser_selection='Chrome',
    sandbox=True
)
# OR
browser.open_chrome_browser(
    'https://robocorp.com/portal',
    sandbox=True
)