Support pagination in iter_bills

This commit is contained in:
Florent 2014-04-01 15:14:28 +02:00
commit a5e55208ae
3 changed files with 23 additions and 2 deletions

View file

@ -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)

View file

@ -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

View file

@ -94,7 +94,6 @@ class INGVirtKeyboard(VirtKeyboard):
return coordinates
class LoginPage(HTMLPage):
def prelogin(self, login, birthday):
# First step : login and birthday