Commit b20d2d81 authored by Quentin Defenouillere's avatar Quentin Defenouillere Committed by Romain Bignon

[binck] Corrected module to work for all users

During login, some connections end up on a 404 error when reaching the
accounts page, so we must hceck what URLs are available on the HomePage
before going anywhere.

Once we know that it is a unique account connection and that we handle
the right accounts URL, the rest of the website is the same.

Closes: 10843@zendesk, 10844@zendesk, 11067@zendesk, 11068@zendesk,
11190@zendesk, 11176@zendesk, 11207@zendesk
parent 958e8f78
......@@ -36,13 +36,14 @@ from .pages import (
class BinckBrowser(LoginBrowser):
BASEURL = 'https://web.binck.fr'
''' Delete this attribute when old website is obsolete '''
old_website_connection = False
unique_account = False
login = URL(r'/Logon', LoginPage)
view = URL('/PersonIntroduction/Index', ViewPage)
logon_flow = URL(r'/AmlQuestionnairesOverview/LogonFlow$', LogonFlowPage)
account = URL(r'/PortfolioOverview/Index', AccountsPage)
accounts = URL(r'/PersonAccountOverview/Index', AccountsPage)
old_accounts = URL(r'/AccountsOverview/Index', OldAccountsPage)
......@@ -63,7 +64,7 @@ class BinckBrowser(LoginBrowser):
def deinit(self):
if self.page and self.page.logged:
self.location('/Account/Logoff')
self.location('https://www.binck.fr/deconnexion-site-client')
super(BinckBrowser, self).deinit()
def do_login(self):
......@@ -93,10 +94,13 @@ class BinckBrowser(LoginBrowser):
@need_login
def iter_accounts(self):
self.accounts.stay_or_go()
if self.unique_account:
self.account.stay_or_go()
else:
self.accounts.stay_or_go()
if self.page.has_accounts_table():
for a in self.page.iter_accounts():
''' Delete these attributes when old website is obsolete '''
a._invpage = None
a._histpages = None
......@@ -116,7 +120,6 @@ class BinckBrowser(LoginBrowser):
# Some Binck connections don't have any accounts on the new AccountsPage,
# so we need to fetch them on the OldAccountsPage for now:
else:
''' Delete this part when old website is obsolete '''
self.old_website_connection = True
self.old_accounts.go()
for a in self.page.iter_accounts():
......@@ -162,7 +165,6 @@ class BinckBrowser(LoginBrowser):
if account._liquidity:
yield create_french_liquidity(account._liquidity)
''' Delete this part when old website is obsolete '''
if self.old_website_connection:
self.old_accounts.stay_or_go().go_to_account(account.id)
if account._invpage:
......@@ -189,7 +191,6 @@ class BinckBrowser(LoginBrowser):
@need_login
def iter_history(self, account):
''' Delete this part when old website is obsolete '''
if self.old_website_connection:
if account._histpages:
for page in account._histpages:
......
......@@ -58,11 +58,15 @@ class ViewPage(LoggedPage, HTMLPage):
class HomePage(LoggedPage, HTMLPage):
# We directly go from the home page to the accounts page
def on_load(self):
''' Remove the old_website_connection part when old website is obsolete '''
if self.browser.old_website_connection:
self.browser.location('https://web.binck.fr/AccountsOverview/Index')
else:
self.browser.location('https://web.binck.fr/PersonAccountOverview/Index')
accounts_url = 'https://web.binck.fr/AccountsOverview/Index'
elif self.doc.xpath('//a[text()="Mes comptes Binck"]'):
accounts_url = 'https://web.binck.fr/PersonAccountOverview/Index'
elif self.doc.xpath('//a[span[text()="Portefeuille"]][@role="button"]'):
self.browser.unique_account = True
accounts_url = 'https://web.binck.fr/PortfolioOverview/Index'
assert accounts_url, 'The accounts URL of this connection is not handled yet!'
self.browser.location(accounts_url)
class ChangePassPage(LoggedPage, HTMLPage):
......
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