use browser2 in boilerplate

This commit is contained in:
Romain Bignon 2014-03-21 23:09:32 +01:00
commit 08adb2a63e
2 changed files with 13 additions and 15 deletions

View file

@ -1,5 +1,5 @@
<%inherit file="layout.py"/>
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser2 import PagesBrowser
from .pages import Page1, Page2
@ -7,19 +7,17 @@ from .pages import Page1, Page2
__all__ = ['${r.classname}Browser']
class ${r.classname}Browser(BaseBrowser):
PROTOCOL = 'http'
DOMAIN = 'www.${r.name}.com'
ENCODING = None
class ${r.classname}Browser(PagesBrowser):
BASEURL = 'http://www.${r.name}.com'
PAGES = {
'%s://%s/page1\?id=.+' % (PROTOCOL, DOMAIN): Page1,
'%s://%s/page2' % (PROTOCOL, DOMAIN): Page2,
}
page1 = URL('/page1\?id=(?P<id>.+)', Page1)
page2 = URL('/page2', Page2)
def get_stuff(self, _id):
self.location('%s://%s/page1?id=%s' % (self.PROTOCOL, self.DOMAIN, _id))
assert self.is_on_page(Page1)
self.page1.go(id=_id)
assert self.page1.is_here()
self.page.do_stuff(_id)
assert self.is_on_page(Page2)
assert self.page2.is_here()
return self.page.do_more_stuff()

View file

@ -1,15 +1,15 @@
<%inherit file="layout.py"/>
from weboob.tools.browser import BasePage
from weboob.tools.browser2 import HTMLPage
__all__ = ['Page1', 'Page2']
class Page1(BasePage):
class Page1(HTMLPage):
def do_stuff(self, _id):
raise NotImplementedError()
class Page2(BasePage):
class Page2(HTMLPage):
def do_more_stuff(self):
raise NotImplementedError()