Commit 0b884402 authored by Florent Viard's avatar Florent Viard Committed by Vincent A

[boursorama] Fixes succesful recipient additions that results in "Recipient not found" errors

When adding recipients, sometimes the process would successfully go to
completion but an error "Recipient not found" would be raised at the
final check.
(ie when we check that the newly added recipient is inside the
recipients list)

The origin of the problem is that on Boursorama side, the recipient list
is global for all accounts.
But for some accounts, the recipient list is prefixed (ex. saving
accounts) or transfer is not allowed (ex. market accounts).

Before, the "origin" account that was used to add the recipient was
selected in a random way as "the first account retrieved by
This was not good as, randomly, an unusable account could have been
selected, like saving accounts.

Boobank does not select an origin_account_id, but if it is the case, we
also have to ensure that the account is valid to add the recipient.
And so, avoid to fail in an unexpected way.
parent 93ee2b51
......@@ -40,6 +40,7 @@ from import (
TransferInvalidEmitter, TransferInvalidLabel, TransferInvalidRecipient,
AddRecipientStep, Rate, TransferBankError, AccountOwnership, RecipientNotFound,
AddRecipientTimeout, TransferDateType, Emitter, TransactionType,
from weboob.capabilities.base import empty, find_object
from import Advisor
......@@ -770,26 +771,46 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser):
def init_new_recipient(self, recipient):
self.recipient_form = None # so it is reset when a new recipient is added
# so it is reset when a new recipient is added
self.recipient_form = None
# get url
# If an account was provided for the recipient, use it
# otherwise use the first checking account available
account = None
for account in self.get_accounts_list():
if account.url:
if not account.url:
if recipient.origin_account_id is None:
if account.type == Account.TYPE_CHECKING:
elif == recipient.origin_account_id:
suffix = 'virements/comptes-externes/nouveau'
if account.url.endswith('/'):
target = account.url + suffix
target = account.url + '/' + suffix
raise AddRecipientBankError(message="Compte ne permettant pas l'ajout de bénéficiaires")
except AccountNotFound:
raise AddRecipientBankError(message="Compte ne permettant pas d'emettre des virements")
assert (
or self.new_transfer_wizard.is_here()
), 'Should be on recipients page'
if not
raise AddRecipientBankError(message="Compte ne permettant pas l'ajout de bénéficiaires")
target = '%s/virements/comptes-externes/nouveau' % account.url.rstrip('/')
assert, 'Not on the page to add recipients.'
# fill recipient form
recipient.origin_account_id =
if recipient.origin_account_id is None:
recipient.origin_account_id =
# confirm sending sms
assert, 'Cannot reach the page asking to send a sms.'
......@@ -804,7 +825,8 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser):
self.recipient_form['account_url'] = account.url
raise AddRecipientStep(recipient, Value('otp_sms', label='Veuillez saisir le code recu par sms'))
# if the add recipient is restarted after the sms has been confirmed recently, the sms step is not presented again
# if the add recipient is restarted after the sms has been confirmed recently,
# the sms step is not presented again
return self.rcpt_after_sms(recipient, account.url)
def new_recipient(self, recipient, **kwargs):
......@@ -814,8 +836,9 @@ class BoursoramaBrowser(RetryLoginBrowser, TwoFactorBrowser):
# validating the sms code directly adds the recipient
account_url = self.send_recipient_form(kwargs['otp_sms'])
return self.rcpt_after_sms(recipient, account_url)
# step 3 of new_recipient (not always used)
elif 'otp_email' in kwargs:
if 'otp_email' in kwargs:
account_url = self.send_recipient_form(kwargs['otp_email'])
return self.check_and_update_recipient(recipient, account_url)
......@@ -40,7 +40,7 @@ from weboob.browser.filters.standard import (
MapIn, Lower, Base,
from weboob.browser.filters.json import Dict
from weboob.browser.filters.html import Attr, Link, TableCell
from weboob.browser.filters.html import Attr, HasElement, Link, TableCell
from import (
Account as BaseAccount, Recipient, Transfer, TransferDateType, AccountNotFound,
AddRecipientBankError, TransferInvalidAmount, Loan, AccountOwnership,
......@@ -1292,6 +1292,9 @@ class TransferRecipients(LoggedPage, HTMLPage):
form['CreditAccount[creditAccountKey]'] = tempid
def is_new_recipient_allowed(self):
return True
class NewTransferWizard(LoggedPage, HTMLPage):
def get_errors(self):
......@@ -1385,6 +1388,13 @@ class NewTransferWizard(LoggedPage, HTMLPage):
def is_new_recipient_allowed(self):
except FormNotFound:
return False
return HasElement('//input[@id="CreditAccount_newBeneficiary"]')(self.doc)
# STEP 3 -
# If using existing recipient: select the amount
# If new beneficiary: select if new recipient is own account or third party one
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