The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

Commit 1cc168ba authored by Martin Lavoie's avatar Martin Lavoie Committed by Vincent A

[s2e] BrowserUnavailable when listing documents

Two situations:
- the request timeout
- the page returns an error
parent 0438c63b
......@@ -418,11 +418,24 @@ def get_profile(self):
@need_login
def iter_documents(self):
self.e_service_page.go(slug=self.SLUG)
try:
self.e_service_page.go(slug=self.SLUG)
except ReadTimeoutError:
raise BrowserUnavailable()
# we might land on the documents page, but sometimes we land on user info "tab"
self.page.select_documents_tab()
self.page.show_more()
# Sometimes, this page can return an error
# Seen messages:
# - Impossible de récupérer les relevés électroniques
# - Le document souhaité n'a pu être généré (délai d'attente dépassé).
# Merci de renouveler votre demande ultérieurement.
error = self.page.get_error_message()
if error:
raise BrowserUnavailable(error)
# Sometimes two documents have the same ID (same date and same type)
existing_id = set()
for document in self.page.iter_documents():
......
......@@ -1251,6 +1251,9 @@ def show_more(self):
self.logger.debug('showing all documents')
form.submit()
def get_error_message(self):
return CleanText('//span[@class="operation-bloc-content-message-erreur-text"]')(self.doc)
@method
class iter_documents(TableElement):
# Note: on this (partial) page, 'head' and 'items' are actually two different HTML tables.
......
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