PageFactory Implementation in Python

657 views
Skip to first unread message

SimSel

unread,
May 7, 2012, 3:01:31 PM5/7/12
to Selenium Users
Hi,

I have seen a similar message posted about a year ago. Still wanted to
confirm if there is a pagefactory implementation in Python or plans of
making one?

Thanks,
S

Luke Inman-Semerau

unread,
May 7, 2012, 3:13:28 PM5/7/12
to seleniu...@googlegroups.com
I don't think one is in the works by anyone on the dev team. Feel free to submit a patch and/or log a new issue for it in the issues list

SimSel

unread,
May 7, 2012, 3:32:05 PM5/7/12
to Selenium Users
Thanks Luke for the quick reply.

On May 7, 12:13 pm, Luke Inman-Semerau <luke.seme...@gmail.com> wrote:
> I don't think one is in the works by anyone on the dev team. Feel free to
> submit a patch and/or log a new issue for it in the issues listhttp://code.google.com/p/selenium/issues/list

Jeremy Kao

unread,
Jun 12, 2015, 1:15:56 AM6/12/15
to seleniu...@googlegroups.com, snneha...@gmail.com
I have created a module called `pageobject_support` that implements PageFactory pattern in a pythonic way. Please refer to the [comment](http://stackoverflow.com/a/30758982/1691598) for more details.

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/
Reply all
Reply to author
Forward
0 new messages