From 3b2b7c7ddd7a96ba90480ac65b1da4ffd3648303 Mon Sep 17 00:00:00 2001 From: Quentin Defenouillere Date: Tue, 29 Jan 2019 15:08:13 +0100 Subject: [PATCH] [cragr] Handle ActionNeeded when first online connection Some cragr web spaces have never been visited before and the user needs to validate CGU before accessing them, so we raise an Action Neede when we reach this specific web page: "operations/interstitielles/premiere-connexion.html" Closes: 35404@sibi, 35582@sibi, 35416@sibi, 9286@zendesk, 9328@zendesk, 9340@zendesk --- modules/cragr/api/browser.py | 3 ++- modules/cragr/api/pages.py | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/cragr/api/browser.py b/modules/cragr/api/browser.py index 11f4a2fa51..37b803e6ae 100644 --- a/modules/cragr/api/browser.py +++ b/modules/cragr/api/browser.py @@ -33,7 +33,7 @@ from weboob.tools.capabilities.bank.transactions import sorted_transactions from .pages import ( - LoginPage, LoggedOutPage, KeypadPage, SecurityPage, ContractsPage, AccountsPage, AccountDetailsPage, + LoginPage, LoggedOutPage, KeypadPage, SecurityPage, ContractsPage, FirstConnectionPage, AccountsPage, AccountDetailsPage, TokenPage, IbanPage, HistoryPage, CardsPage, CardHistoryPage, NetfincaRedirectionPage, PredicaRedirectionPage, PredicaInvestmentsPage, ProfilePage, ProfileDetailsPage, ProProfileDetailsPage, ) @@ -50,6 +50,7 @@ class CragrAPI(LoginBrowser): login_page = URL(r'particulier/acceder-a-mes-comptes.html$', LoginPage) keypad = URL(r'particulier/acceder-a-mes-comptes.authenticationKeypad.json', KeypadPage) security_check = URL(r'particulier/acceder-a-mes-comptes.html/j_security_check', SecurityPage) + first_connection = URL(r'.*/operations/interstitielles/premiere-connexion.html', FirstConnectionPage) logged_out = URL(r'.*', LoggedOutPage) token_page = URL(r'libs/granite/csrf/token.json', TokenPage) diff --git a/modules/cragr/api/pages.py b/modules/cragr/api/pages.py index 5b323680a7..8cfe987c10 100644 --- a/modules/cragr/api/pages.py +++ b/modules/cragr/api/pages.py @@ -25,6 +25,7 @@ import dateutil from weboob.browser.pages import HTMLPage, JsonPage, LoggedPage +from weboob.exceptions import ActionNeeded from weboob.capabilities import NotAvailable from weboob.capabilities.bank import ( Account, AccountOwnerType, Transaction, Investment, @@ -68,6 +69,13 @@ def is_here(self): return self.doc.xpath('//b[text()="FIN DE CONNEXION"]') +class FirstConnectionPage(LoggedPage, HTMLPage): + def on_load(self): + message = CleanText('//p[contains(text(), "votre première visite")]')(self.doc) + if message: + raise ActionNeeded(message) + + class SecurityPage(JsonPage): def get_accounts_url(self): return Dict('url')(self.doc) -- GitLab