From a8f8936d132b9b97404dc9f8dea63455ac8bde05 Mon Sep 17 00:00:00 2001 From: Christophe Francois Date: Tue, 10 Nov 2020 15:43:35 +0100 Subject: [PATCH] [boursorama] Manage minor user page Users under 18 can't access their accounts, we raise NoAccountsException. --- modules/boursorama/browser.py | 8 +++++--- modules/boursorama/pages.py | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/boursorama/browser.py b/modules/boursorama/browser.py index c1a4afe542..9fee667a61 100644 --- a/modules/boursorama/browser.py +++ b/modules/boursorama/browser.py @@ -55,7 +55,7 @@ TransferAccounts, TransferRecipients, TransferCharacteristics, TransferConfirm, TransferSent, AddRecipientPage, StatusPage, CardHistoryPage, CardCalendarPage, CurrencyListPage, CurrencyConvertPage, AccountsErrorPage, NoAccountPage, TransferMainPage, PasswordPage, NewTransferWizard, - NewTransferConfirm, NewTransferSent, CardSumDetailPage, + NewTransferConfirm, NewTransferSent, CardSumDetailPage, MinorPage, ) from .transfer_pages import TransferListPage, TransferInfoPage @@ -84,7 +84,7 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser): ErrorPage ) login = URL(r'/connexion/saisie-mot-de-passe', PasswordPage) - + minor = URL(r'/connexion/mineur', MinorPage) accounts = URL(r'/dashboard/comptes\?_hinclude=300000', AccountsPage) accounts_error = URL(r'/dashboard/comptes\?_hinclude=300000', AccountsErrorPage) pro_accounts = URL(r'/dashboard/comptes-professionnels\?_hinclude=1', AccountsPage) @@ -263,7 +263,9 @@ def init_login(self): self.login.go() self.page.enter_password(self.username, self.password) - if self.error.is_here(): + if self.minor.is_here(): + raise NoAccountsException(self.page.get_error_message()) + elif self.error.is_here(): raise BrowserIncorrectPassword() elif self.login.is_here(): error = self.page.get_error() diff --git a/modules/boursorama/pages.py b/modules/boursorama/pages.py index 06e4b16605..6dcf5499d8 100644 --- a/modules/boursorama/pages.py +++ b/modules/boursorama/pages.py @@ -1111,6 +1111,11 @@ def on_load(self): raise ActionNeeded(error) +class MinorPage(HTMLPage): + def get_error_message(self): + return CleanText('//div[@id="modal-main-content"]//p')(self.doc) + + class ExpertPage(LoggedPage, HTMLPage): pass -- GitLab