From db86fe1cbd47819142624caddc3e1aa2b767dcb3 Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 28 Jul 2015 22:33:22 +0200 Subject: [PATCH] ameli: prevents crashes when no bills are available --- modules/ameli/pages.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/ameli/pages.py b/modules/ameli/pages.py index 58f9b2d0..a23659ed 100644 --- a/modules/ameli/pages.py +++ b/modules/ameli/pages.py @@ -175,7 +175,11 @@ class PaymentDetailsPage(AmeliBasePage): class BillsPage(AmeliBasePage): def iter_bills(self, sub): - table = self.doc.xpath('//table[@id="relevesMensuels"]')[0].xpath('.//tr') + try: + table = self.doc.xpath('//table[@id="relevesMensuels"]')[0].xpath('.//tr') + # When no operations was done in the last month, there is no table. That is fine. + except IndexError: + return for tr in table: list_tds = tr.xpath('.//td') if len(list_tds) == 0: