Does Webdriver support pagefactory for Python?

前端 未结 3 1175
一向
一向 2021-02-15 23:05

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

3条回答
  •  别跟我提以往
    2021-02-15 23:46

    Dynamically-typed languages like Python are less obsessed by design patterns to create objects - because it is trivially easy just create object of any type (with proper methods) and return it. Patterns are common solutions to common problems. If something is not a problem, you don't need a pattern to deal with it :-) OOP was initially a design pattern in C.

    Edit, Dec 2017:

    In our homegrown framework for page automation (for automated UI testing and other purposes), we do use pageobject design pattern, but had no need for a page factory. Old-school inheritance from our custom BasePage covered all our (quite diversified) needs. We do use few tricks to create page elements and make sure that proper page was instantiated, and based on that experience I like that our PageObject is simple.

    Also, Python allows for multiple inheritance, if your needs grow more complicated.

    In my experience (using Python, Selenium and WebDriver for more than 5 years now), lack of page factory pattern is a sign that you don't need it, not that it cannot be implemented.

提交回复
热议问题