From e2d88f103fad168fcd7c76800110deed48eb2202 Mon Sep 17 00:00:00 2001 From: Quentin Defenouillere Date: Wed, 23 Sep 2020 16:20:45 +0200 Subject: [PATCH] [cragr] Corrected get_profile Sometimes profile details are not available, leading to a 404 error. --- modules/cragr/browser.py | 12 ++++++++---- modules/cragr/pages.py | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/cragr/browser.py b/modules/cragr/browser.py index 9321eb0ae5..bbd3b2424e 100644 --- a/modules/cragr/browser.py +++ b/modules/cragr/browser.py @@ -914,16 +914,20 @@ def get_profile(self): # 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): diff --git a/modules/cragr/pages.py b/modules/cragr/pages.py index 9e33f50936..48733aebdc 100644 --- a/modules/cragr/pages.py +++ b/modules/cragr/pages.py @@ -314,6 +314,9 @@ def get_connection_id(self): 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 -- GitLab