Commit e2d88f10 authored by Quentin Defenouillere's avatar Quentin Defenouillere Committed by Vincent A

[cragr] Corrected get_profile

Sometimes profile details are not available, leading to a 404 error.
parent 4cb855f5
......@@ -914,16 +914,20 @@ class CreditAgricoleBrowser(LoginBrowser, StatesMixin):
# There is one profile per space, so we only fetch the first one
self.go_to_account_space(0)
owner_type = self.page.get_owner_type()
profile_details = self.page.has_profile_details()
self.profile_page.go(space=self.space)
if owner_type == 'PRIV':
profile = self.page.get_user_profile()
self.profile_details.go(space=self.space)
self.page.fill_profile(obj=profile)
if profile_details:
self.profile_details.go(space=self.space)
self.page.fill_profile(obj=profile)
return profile
elif owner_type == 'ORGA':
profile = self.page.get_company_profile()
self.pro_profile_details.go(space=self.space)
self.page.fill_profile(obj=profile)
if profile_details:
self.pro_profile_details.go(space=self.space)
self.page.fill_profile(obj=profile)
return profile
def get_space_info(self):
......
......@@ -314,6 +314,9 @@ class AccountsPage(LoggedPage, JsonPage):
def has_main_account(self):
return Dict('comptePrincipal', default=None)(self.doc)
def has_profile_details(self):
return CleanText('//a[text()="Gérer mes coordonnées"]')(self.html_doc)
@method
class get_main_account(ItemElement):
klass = Account
......
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