Commit d413a956 authored by Martin Sicot's avatar Martin Sicot Committed by Romain Bignon

[fortuneo] Avoid fake ActionNeeded

A choice present on the main pages threw ActionNeeded. We now chose the
option 'later' whenever connecting.
fix:9019@zendesk
parent a6d9db5b
......@@ -32,7 +32,7 @@ from weboob.tools.value import Value
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 @@ class Fortuneo(LoginBrowser, StatesMixin):
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
......
......@@ -452,6 +452,9 @@ class AccountsList(LoggedPage, HTMLPage):
'| //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 @@ class AccountsList(LoggedPage, HTMLPage):
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment