[Python] AUTOMATISATION_FactTemsys [closed]

Discussão em 'Python' iniciado por Stack, Maio 15, 2025.

  1. Stack

    Stack Membro Participativo

    I have developed a code via Robocorp and I have a problem. The mission is to upload a csv file to a financer's platform to be able to track paid and unpaid invoices. At one point in the code, I asked the bot to click on an icon and wait for another “download” icon to appear, but it had trouble catching that icon. I gave it several selectors but nothing helped. here's the code:

    # Cliquez sur le bouton "Exporter"
    browser_lib.click_element("xpath://button[contains(., 'Exporter')]")
    logger.info("Bouton 'Exporter' cliqué")

    # Cliquer sur l’icône de téléchargement
    browser_lib.wait_until_element_is_visible(
    "xpath://a-action-icon[@icon='insert_drive_file']", timeout=30
    )
    browser_lib.click_element(
    "xpath://a-action-icon[@icon='insert_drive_file']"
    )
    logger.info("Clic sur le bouton de téléchargement (insert_drive_file) effectué.")

    # Attendre que le fichier soit téléchargé (max. 40 secondes)
    downloads_folder = os.path.join(os.path.expanduser("~"), 'Downloads')
    downloaded_file = None
    start_time = time.time()
    while time.time() - start_time < 40:
    list_of_files = glob.glob(os.path.join(downloads_folder, '*.xls*'))
    if not list_of_files:
    list_of_files = glob.glob(os.path.join(downloads_folder, '*.xlsx'))
    if list_of_files:
    downloaded_file = max(list_of_files, key=os.path.getctime)
    break
    time.sleep(1)

    if downloaded_file:
    logger.info(f"Fichier téléchargé trouvé : {downloaded_file}")
    else:
    logger.error("Aucun fichier exporté trouvé après 40 secondes")

    logger.info("Tâche terminée avec succès")

    except Exception as e:
    logger.error(f"Erreur rencontrée : {e}")
    logger.error(traceback.format_exc())
    try:
    if browser_lib.get_browser_aliases():
    screenshot_path = os.path.join(os.getcwd(), "erreur_connexion.png")
    browser_lib.capture_page_screenshot(screenshot_path)
    logger.info(f"Capture d’écran enregistrée : {screenshot_path}")
    except Exception:
    pass
    finally:
    browser_lib.close_browser()


    here are the elements I have: arrow_downward

    Rel cssselector : body > div:nth-child(5) > div:nth-child(1) > div:nth-child(2) > o-export-management-popup:nth-child(1) > div:nth-child(1) > div:nth-child(4) > p-table:nth-child(1) > div:nth-child(1) > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(7) > m-export-management-status:nth-child(1) > div:nth-child(1) > button:nth-child(2) > mat-icon:nth-child(1)

    Rel Xpath : //tbody/tr1/td[7]/m-export-management-status1/div1/button1/mat-icon[1]enter image description here

    Continue reading...

Compartilhe esta Página