BasePage

Page is the main concept of Page Object pattern. In order to create your pages you should inherit webium.base_page.BasePage.

from webium import BasePage


class MyPage(BasePage):
    pass

url

If your page has static url you can specify it in __init__. After that you can use open() method to open your page.

url can be also defined as static attribute of your class.

from webium import BasePage


class PageWithUrl(BasePage):
    def __init__(self):
        super(PageWithUrl, self).__init__(url='http://wargaming.com/')


if __name__ == '__main__':
    page = PageWithUrl()
    page.open()

driver

Pages should have some WebDriver instance in order to manipulate browser. By default Webium will create the instance of WebDriver class specified in `webium.settings.driver_class. If you want to get the instance of the the driver you can call webium.driver.get_driver() method.

driver parameter in BasePage gives you an ability to handle WebDriver instance by yourself.

from selenium.webdriver import Firefox
from webium import BasePage


class DriverHandlingPage(BasePage):
    def __init__(self, *args, **kwargs):
        super(DriverHandlingPage, self).__init__(url='http://wargaming.net/', *args, **kwargs)


if __name__ == '__main__':
    my_driver = Firefox()
    page = DriverHandlingPage(driver=my_driver)
    page.open()
    print('Page title: ' + my_driver.title)
    my_driver.quit()