From b831f2be5dc5178c617a4b679d4959e7fc6a08bf Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 22 Sep 2022 20:02:56 +0100 Subject: [PATCH] LCL downloader go back to legacy version --- ofx_processor/downloaders/lcl.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ofx_processor/downloaders/lcl.py b/ofx_processor/downloaders/lcl.py index 7ce7078..386c080 100644 --- a/ofx_processor/downloaders/lcl.py +++ b/ofx_processor/downloaders/lcl.py @@ -3,6 +3,7 @@ from pathlib import Path import click from selenium import webdriver +from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.by import By from selenium.webdriver.support.select import Select @@ -40,10 +41,10 @@ class LclDownloader: selenium.get("https://monespace.lcl.fr/connexion") try: self._click(By.ID, "popin_tc_privacy_button_2") - except: - # If the user has already accepted the privacy policy, - # the button is not present - pass + click.secho("Accepting privacy policy...") + except NoSuchElementException: + click.secho("Privacy policy already accepted") + login_input = selenium.find_element(By.ID, "identifier") login_input.send_keys(self.config.bank_identifier) self._click(By.CLASS_NAME, "app-cta-button") @@ -52,6 +53,12 @@ class LclDownloader: self._click(By.CLASS_NAME, "app-cta-button") click.secho("Logged in!", fg="green") + try: + self._click(By.CSS_SELECTOR, ".menu-link.to-legacy") + click.secho("Going back to legacy version...") + except NoSuchElementException: + click.secho("Already on legacy version.") + click.secho("Navigating through archives...", fg="blue") self._click(By.ID, "linkSynthese") self._click(By.CLASS_NAME, "picDl")