I was reading about page objects and design patterns on the Webdriver project site and came across pagefactory. It doesn\'t look like the Webdriver for Python API includes page
I have created a module called pageobject_support
that implements PageFactory pattern in a pythonic way.
With this module, Google Search page could be modelled as follows:
from pageobject_support import cacheable, callable_find_by as find_by
from selenium.webdriver.common.by.By
class GoogleSearchPage(object):
_search_box = find_by(how=By.NAME, using='q', cacheable=True)
_search_button = find_by(name='btnK')
def __init__(self, driver):
self._driver = driver
def search(self, keywords):
self._search_box().click()
self._search_box().send_keys(keywords)
self._search_button().click()
Your feedback is appreciated. For more details, please visit https://jeremykao.wordpress.com/2015/06/10/pagefactory-pattern-in-python/