From a5e55208aea56126525091bc7f44b57e14fd7d7e Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 1 Apr 2014 15:14:28 +0200 Subject: [PATCH] Support pagination in iter_bills --- modules/ing/browser.py | 4 +++- modules/ing/pages/bills.py | 20 ++++++++++++++++++++ modules/ing/pages/login.py | 1 - 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/modules/ing/browser.py b/modules/ing/browser.py index 06c905ba..44ab29b4 100644 --- a/modules/ing/browser.py +++ b/modules/ing/browser.py @@ -71,6 +71,8 @@ class IngBrowser(LoginBrowser): self.page.login(self.password) if self.page.error(): raise BrowserIncorrectPassword() + if self.errorpage.is_here(): + raise BrowserIncorrectPassword('Please login on website to fill the form and retry') @need_login def get_accounts_list(self): @@ -227,7 +229,7 @@ class IngBrowser(LoginBrowser): "transfer_issuer_radio": subscription.id } self.billpage.go(data=data) - return self.page.iter_bills(subid=subscription.id) + return self.pagination(lambda: self.page.iter_bills(subid=subscription.id)) def predownload(self, bill): self.page.postpredown(bill._localid) diff --git a/modules/ing/pages/bills.py b/modules/ing/pages/bills.py index a6b3ae21..60ddec96 100644 --- a/modules/ing/pages/bills.py +++ b/modules/ing/pages/bills.py @@ -57,6 +57,26 @@ class BillsPage(LoggedPage, HTMLPage): class iter_bills(ListElement): item_xpath = '//ul[@id="statements_form:statementsel"]/li' + def next_page(self): + lis = self.page.doc.xpath('//form[@name="years_form"]//li') + selected = False + ref = None + for li in lis: + if "rich-list-item selected" in li.attrib['class']: + selected = True + else: + if selected: + ref = li.find('a').attrib['id'] + break + if ref is None: + return + form = self.page.get_form(name="years_form") + form.pop('years_form:j_idcl') + form.pop('years_form:_link_hidden_') + form['AJAXREQUEST'] = "years_form:year_region" + form[ref] = ref + return form.request + class item(ItemElement): klass = Bill diff --git a/modules/ing/pages/login.py b/modules/ing/pages/login.py index d44598a0..afb65bec 100644 --- a/modules/ing/pages/login.py +++ b/modules/ing/pages/login.py @@ -94,7 +94,6 @@ class INGVirtKeyboard(VirtKeyboard): return coordinates - class LoginPage(HTMLPage): def prelogin(self, login, birthday): # First step : login and birthday