From ef9738402b8d9c580513c58b94170c359b929a36 Mon Sep 17 00:00:00 2001 From: Sylvie Ye Date: Thu, 26 Jul 2018 16:55:50 +0200 Subject: [PATCH] [gmf] handle document signature page Some users have to sign documents. It can be skipped by going on Account page. But account page can also be redirected on document signature page like this: AccountsPage(GET) -> DocumentsSignaturePage -> AccountsPage(GET) -> DocumentsSignaturePage Plus, for transaction and investment it's a POST request, document signature page can be here after the post. Every pages can be redirected like this in go_details_page: AccountsPage(GET) -> DocumentsSignaturePage AccountsPage(GET) -> TransactionsInvestmentsPage(POST) -> DocumentsSignaturePage It's easier to raise ActionNeeded. Closes: 15699@sibi --- modules/gmf/browser.py | 6 +++++- modules/gmf/pages.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/gmf/browser.py b/modules/gmf/browser.py index 6f51d76379..859e463178 100644 --- a/modules/gmf/browser.py +++ b/modules/gmf/browser.py @@ -22,7 +22,10 @@ from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword -from .pages import LoginPage, AccountsPage, TransactionsInvestmentsPage, AllTransactionsPage +from .pages import ( + LoginPage, AccountsPage, TransactionsInvestmentsPage, AllTransactionsPage, + DocumentsSignaturePage, +) class GmfBrowser(LoginBrowser): @@ -32,6 +35,7 @@ class GmfBrowser(LoginBrowser): accounts = URL(r'/pointentree/client/homepage', AccountsPage) transactions_investments = URL(r'/pointentree/contratvie/detailsContrats', TransactionsInvestmentsPage) all_transactions = URL(r'/pages/contratvie/detailscontrats/.*\.faces', AllTransactionsPage) + documents_signature = URL(r'/public/pages/authentification/.*\.faces', DocumentsSignaturePage) def do_login(self): self.login.go().login(self.username, self.password) diff --git a/modules/gmf/pages.py b/modules/gmf/pages.py index 8807e9f029..22a641ba10 100644 --- a/modules/gmf/pages.py +++ b/modules/gmf/pages.py @@ -30,6 +30,7 @@ from weboob.browser.filters.html import Attr, TableCell from weboob.capabilities.base import NotAvailable from weboob.tools.capabilities.bank.transactions import FrenchTransaction +from weboob.exceptions import ActionNeeded class Transaction(FrenchTransaction): @@ -166,3 +167,9 @@ def build_doc(self, content): investments_html = xml.xpath('//partial-response/changes/update[2]')[0].text.encode(encoding=self.encoding) html = transactions_html + investments_html return HTMLPage.build_doc(self, html) + + +class DocumentsSignaturePage(LoggedPage, HTMLPage): + def on_load(self): + if self.doc.xpath('//span[contains(text(), "VO(S) DOCUMENT(S) A SIGNER")]'): + raise ActionNeeded(CleanText('//div[@class="block"]/p[contains(text(), "Vous avez un ou plusieurs document(s) à signer")]')(self.doc)) -- GitLab