diff --git a/modules/lcl/pages.py b/modules/lcl/pages.py index 7691e378d9404ff2ec9a4a3a1c57df3aa46d2593..be46ac0b57f7fca1a6e5fc478cd71adc7c8f547a 100644 --- a/modules/lcl/pages.py +++ b/modules/lcl/pages.py @@ -1718,6 +1718,24 @@ def get_authent_mechanism(self): elif self.doc.xpath('//script[contains(text(), "AuthentForteDesktop")]'): return 'app_validation' + def get_phone_attributes(self): + # The number which begin by 06 or 07 is not always referred as MOBILE number + # this function parse the html tag of the phone number which begins with 06 or 07 + # to determine the canal attributed by the website, it can be MOBILE or FIXE + phone = {} + for phone_tag in self.doc.xpath('//div[@class="choixTel"]//div[@class="selectTel"]'): + phone['attr_id'] = Attr('.', 'id')(phone_tag) + phone['number'] = CleanText('.//a[@id="fixIpad"]')(phone_tag) + if phone['number'].startswith('06') or phone['number'].startswith('07'): + # Let's take the first mobile phone + # If no mobile phone is available, we take last phone found (ex: 01) + break + assert phone['attr_id'], 'no phone found for 2FA' + canal = re.match('envoi(Fixe|Mobile)', phone['attr_id']) + assert canal, 'Canal unknown %s' % phone['attr_id'] + phone['attr_id'] = canal.group(1).upper() + return phone + class DocumentsPage(LoggedPage, HTMLPage): def do_search_request(self): @@ -1790,24 +1808,6 @@ def is_here(self): default=None )(self.doc) - def get_phone_attributes(self): - # The number which begin by 06 or 07 is not always referred as MOBILE number - # this function parse the html tag of the phone number which begins with 06 or 07 - # to determine the canal attributed by the website, it can be MOBILE or FIXE - phone = {} - for phone_tag in self.doc.xpath('//div[@class="choixTel"]//div[@class="selectTel"]'): - phone['attr_id'] = Attr('.', 'id')(phone_tag) - phone['number'] = CleanText('.//a[@id="fixIpad"]')(phone_tag) - if phone['number'].startswith('06') or phone['number'].startswith('07'): - # Let's take the first mobile phone - # If no mobile phone is available, we take last phone found (ex: 01) - break - assert phone['attr_id'], 'no phone found for 2FA' - canal = re.match('envoi(Fixe|Mobile)', phone['attr_id']) - assert canal, 'Canal unknown %s' % phone['attr_id'] - phone['attr_id'] = canal.group(1).upper() - return phone - def get_app_validation_msg(self): return Coalesce( CleanText('//form[@id="formNoSend"]//div[@id="polling"]//div[contains(text(), "application")]'),