Commit 3d361e82 authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by Vincent A

[boursorama] Handle new recipients page

Some users have a different page on which they need to go to have the
list of their recipients.
parent b95077ff
...@@ -50,7 +50,8 @@ from .pages import ( ...@@ -50,7 +50,8 @@ from .pages import (
CardsNumberPage, CalendarPage, HomePage, PEPPage, CardsNumberPage, CalendarPage, HomePage, PEPPage,
TransferAccounts, TransferRecipients, TransferCharac, TransferConfirm, TransferSent, TransferAccounts, TransferRecipients, TransferCharac, TransferConfirm, TransferSent,
AddRecipientPage, StatusPage, CardHistoryPage, CardCalendarPage, CurrencyListPage, CurrencyConvertPage, AddRecipientPage, StatusPage, CardHistoryPage, CardCalendarPage, CurrencyListPage, CurrencyConvertPage,
AccountsErrorPage, NoAccountPage, TransferMainPage, PasswordPage, AccountsErrorPage, NoAccountPage, TransferMainPage, PasswordPage, NewTransferRecipients,
NewTransferAccounts,
) )
from .transfer_pages import TransferListPage, TransferInfoPage from .transfer_pages import TransferListPage, TransferInfoPage
...@@ -121,6 +122,15 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser): ...@@ -121,6 +122,15 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser):
r'/compte/(?P<type>[^/]+)/(?P<webid>\w+)/virements/nouveau/(?P<id>\w+)/2', r'/compte/(?P<type>[^/]+)/(?P<webid>\w+)/virements/nouveau/(?P<id>\w+)/2',
TransferRecipients TransferRecipients
) )
new_transfer_accounts = URL(
r'/compte/(?P<acc_type>[^/]+)/(?P<webid>\w+)/virements/immediat/nouveau/?$',
r'/compte/(?P<type>[^/]+)/(?P<webid>\w+)/virements/immediat/nouveau/(?P<id>\w+)/1',
NewTransferAccounts
)
new_recipients_page = URL(
r'/compte/(?P<type>[^/]+)/(?P<webid>\w+)/virements/immediat/nouveau/(?P<id>\w+)/2',
NewTransferRecipients
)
transfer_charac = URL( transfer_charac = URL(
r'/compte/(?P<type>[^/]+)/(?P<webid>\w+)/virements/nouveau/(?P<id>\w+)/3', r'/compte/(?P<type>[^/]+)/(?P<webid>\w+)/virements/nouveau/(?P<id>\w+)/3',
TransferCharac TransferCharac
...@@ -560,6 +570,9 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser): ...@@ -560,6 +570,9 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser):
if self.transfer_accounts.is_here(): if self.transfer_accounts.is_here():
self.page.submit_account(account_id) # may raise AccountNotFound self.page.submit_account(account_id) # may raise AccountNotFound
elif self.transfer_main_page.is_here():
self.new_transfer_accounts.go(acc_type=account_type, webid=account_webid)
self.page.submit_account(account_id) # may raise AccountNotFound
@need_login @need_login
def iter_transfer_recipients(self, account): def iter_transfer_recipients(self, account):
...@@ -572,7 +585,11 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser): ...@@ -572,7 +585,11 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser):
except (BrowserHTTPNotFound, AccountNotFound): except (BrowserHTTPNotFound, AccountNotFound):
return [] return []
assert self.recipients_page.is_here() assert (
self.recipients_page.is_here()
or self.new_recipients_page.is_here()
), 'Should be on recipients page'
return self.page.iter_recipients() return self.page.iter_recipients()
def check_basic_transfer(self, transfer): def check_basic_transfer(self, transfer):
......
...@@ -1255,6 +1255,60 @@ class TransferRecipients(LoggedPage, HTMLPage): ...@@ -1255,6 +1255,60 @@ class TransferRecipients(LoggedPage, HTMLPage):
form.submit() form.submit()
class NewTransferRecipients(LoggedPage, HTMLPage):
@method
class iter_recipients(ListElement):
item_xpath = '//div[contains(@id, "panel-")]//div[contains(@class, "panel__body")]//label'
class item(ItemElement):
klass = Recipient
obj_id = CleanText(
'.//span[contains(@class, "sub-label")]/span[not(contains(@class,"sub-label"))]',
replace=[(' ', '')],
)
obj_label = Regexp(
CleanText('.//span[contains(@class, "account-label")]'),
r'([^-]+)',
'\\1',
)
def obj_category(self):
text = CleanText(
'./ancestor::div[contains(@class, "panel__body")]'
+ '/preceding-sibling::div[contains(@class, "panel__header")]'
+ '//span[contains(@class, "panel__title")]'
)(self).lower()
if 'mes comptes boursorama banque' in text:
return 'Interne'
elif any(exp in text for exp in ('comptes externes', 'comptes de tiers', 'mes bénéficiaires')):
return 'Externe'
def obj_iban(self):
if Field('category')(self) == 'Externe':
return Field('id')(self)
return NotAvailable
def obj_enabled_at(self):
return datetime.datetime.now().replace(microsecond=0)
obj__tempid = Attr('./input', 'value')
class NewTransferAccounts(LoggedPage, HTMLPage):
def submit_account(self, account_id):
form = self.get_form()
debit_account = CleanText(
'//input[./following-sibling::div/span/span[contains(text(), "%s")]]/@value' % account_id
)(self.doc)
if not debit_account:
raise AccountNotFound()
form['DebitAccount[debit]'] = debit_account
form.submit()
class TransferCharac(LoggedPage, HTMLPage): class TransferCharac(LoggedPage, HTMLPage):
def get_option(self, select, text): def get_option(self, select, text):
for opt in select.xpath('option'): for opt in select.xpath('option'):
......
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