From 3fb8706d61f712665170fb905a60abb2ec28df5d Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 13 Feb 2012 10:34:15 +0100 Subject: [PATCH] The account listing is now more robust Hello, actually I didn't write this patch. The new contributor is David Jeanneteau. Regards, Florent. Signed-off-by: Florent Signed-off-by: Romain Bignon --- modules/ing/pages/accounts_list.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/ing/pages/accounts_list.py b/modules/ing/pages/accounts_list.py index cf36c972..df4ea21d 100644 --- a/modules/ing/pages/accounts_list.py +++ b/modules/ing/pages/accounts_list.py @@ -34,16 +34,20 @@ class AccountsList(BasePage): def get_list(self): l = [] + ids = [] for td in self.document.xpath('.//td[@nowrap="nowrap"]'): account = Account() link = td.xpath('.//a')[0] account.id = re.search('\d', link.attrib['href']).group(0) - account.label = link.text - urltofind = './/a[@href="' + link.attrib['href'] + '"]' - linkbis = self.document.xpath(urltofind).pop() - account.balance = float(linkbis.text.replace('.', '').replace(',','.')) - account.coming = NotAvailable - l.append(account) - - return l + if not ( account.id in ids ) : + ids.append( account.id ) + account.label = link.text + urltofind = './/a[@href="' + link.attrib['href'] + '"]' + linkbis = self.document.xpath(urltofind).pop() + if linkbis.text == link.text : + linkbis=self.document.xpath(urltofind)[1] + account.balance = float( linkbis.text.replace('.','').replace(' ', '').replace(',','.') ) + account.coming = NotAvailable + l.append(account) + return l