diff --git a/modules/fortuneo/browser.py b/modules/fortuneo/browser.py index 7d587b48c4a9f6b3e5c1aaf88b89d4065fa62f5b..cb57a68094a58b3a54531903eac647be5e85ce7a 100644 --- a/modules/fortuneo/browser.py +++ b/modules/fortuneo/browser.py @@ -32,7 +32,7 @@ from .pages.login import LoginPage, UnavailablePage from .pages.accounts_list import ( - AccountsList, AccountHistoryPage, CardHistoryPage, InvestmentHistoryPage, PeaHistoryPage, LoanPage, ProfilePage, ProfilePageCSV, SecurityPage, + AccountsList, AccountHistoryPage, CardHistoryPage, InvestmentHistoryPage, PeaHistoryPage, LoanPage, ProfilePage, ProfilePageCSV, SecurityPage, FakeActionPage, ) from .pages.transfer import ( RegisterTransferPage, ValidateTransferPage, ConfirmTransferPage, RecipientsPage, RecipientSMSPage @@ -84,7 +84,7 @@ class Fortuneo(LoginBrowser, StatesMixin): r'fr/prive/mes-comptes/compte-courant/.*/init-confirmer-saisie-virement.jsp', r'/fr/prive/mes-comptes/compte-courant/.*/confirmer-saisie-virement.jsp', ConfirmTransferPage) - + fake_action_page = URL(r'fr/prive/mes-comptes/synthese-globale/synthese-mes-comptes.jsp', FakeActionPage) profile = URL(r'/fr/prive/informations-client.jsp', ProfilePage) profile_csv = URL(r'/PdfStruts\?*', ProfilePageCSV) @@ -160,7 +160,17 @@ def get_accounts_list(self): self.process_action_needed() assert self.accounts_page.is_here() - return self.page.get_list() + accounts_list = self.page.get_list() + if self.fake_action_page.is_here(): + # A false action needed is present, it's a choice to make Fortuno your main bank. + # To avoid it, we need to first detect it on the account_page + # Then make a post request to mimic the click on choice 'later' + # And to finish we must to reload the page with a POST to get the accounts + # before going on the accounts_page, which will have the data. + self.location(self.absurl('ReloadContext?action=1&', base=True), method='POST') + self.accounts_page.go() + accounts_list = self.page.get_list() + return accounts_list def process_action_needed(self): # we have to go in an iframe to know if there are CGUs diff --git a/modules/fortuneo/pages/accounts_list.py b/modules/fortuneo/pages/accounts_list.py index d90c808dad9172a52e1577fac7ce76f3c4726ebd..e9add0e6bead7c0abbe0fe7b0aee1a2cffbbc2e5 100644 --- a/modules/fortuneo/pages/accounts_list.py +++ b/modules/fortuneo/pages/accounts_list.py @@ -452,6 +452,9 @@ def get_list(self): '| //div[@id="as_renouvellementMotDePasse.do_"]//p[contains(text(), "votre mot de passe")]' '| //div[@id="as_afficherSecuriteForteOTPIdentification.do_"]//span[contains(text(), "Pour valider ")]') if global_error_message: + if "Et si vous faisiez de Fortuneo votre banque principale" in CleanText(global_error_message)(self): + self.browser.location('/ReloadContext', data={'action': 4}) + return raise ActionNeeded(CleanText('.')(global_error_message[0])) local_error_message = page.doc.xpath('//div[@id="error"]/p[@class="erreur_texte1"]') if local_error_message: @@ -501,6 +504,9 @@ def get_list(self): return accounts +class FakeActionPage(LoggedPage, HTMLPage): + pass + class LoanPage(LoggedPage, HTMLPage): def get_balance(self): return CleanText(u'//p[@id="c_montantRestant"]//strong')(self.doc)