From 9cb1daf4e5cf9d5ba5c95c216a5978f7f5733e3a Mon Sep 17 00:00:00 2001 From: Maxime Gasselin Date: Tue, 6 Nov 2018 13:41:11 +0100 Subject: [PATCH] [fortuneo] Add recipient: Handle validation when the first sms is expired Here we inform the user to use the new sms code. It happens when user waits more than 5 minutes to enter its code. We also catch error message when the code validation is unsuccessful. Closes: 7689@zendesk --- modules/fortuneo/browser.py | 10 +++++++--- modules/fortuneo/pages/transfer.py | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/fortuneo/browser.py b/modules/fortuneo/browser.py index 89b91175d8..7d587b48c4 100644 --- a/modules/fortuneo/browser.py +++ b/modules/fortuneo/browser.py @@ -207,12 +207,16 @@ def copy_recipient(self, recipient): def new_recipient(self, recipient, **params): if 'code' in params: - self.need_reload_state = None # to drop and use self.add_recipient_form instead in send_code() recipient_form = json.loads(self.add_recipient_form) self.send_code(recipient_form ,params['code']) - assert self.page.rcpt_after_sms() - return self.copy_recipient(recipient) + if self.page.rcpt_after_sms(): + self.need_reload_state = None + return self.copy_recipient(recipient) + elif self.page.is_code_expired(): + self.need_reload_state = True + raise AddRecipientStep(recipient, Value('code', label='Le code sécurité est expiré. Veuillez saisir le nouveau code reçu qui sera valable 5 minutes.')) + assert False, self.page.get_error() return self.new_recipient_before_otp(recipient, **params) @need_login diff --git a/modules/fortuneo/pages/transfer.py b/modules/fortuneo/pages/transfer.py index 9113903fe5..4f67be32b4 100644 --- a/modules/fortuneo/pages/transfer.py +++ b/modules/fortuneo/pages/transfer.py @@ -116,10 +116,16 @@ def get_send_code_form_input(self): form = self.get_form() return form + def is_code_expired(self): + return self.doc.xpath('//label[contains(text(), "Le code sécurité est expiré. Veuillez saisir le nouveau code reçu")]') + def rcpt_after_sms(self): return self.doc.xpath('//div[@class="confirmationAjoutCompteExterne"]\ /h2[contains(text(), "ajout de compte externe a bien été prise en compte")]') + def get_error(self): + return CleanText().filter(self.doc.xpath('//form[@id="CompteExterneActionForm"]//p[@class="container error"]//label[@class="error]')) + class RegisterTransferPage(LoggedPage, HTMLPage): @method -- GitLab