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

View file

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