Does Webdriver support pagefactory for Python?

前端 未结 3 738
囚心锁ツ
囚心锁ツ 2021-02-15 23:18

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:50

    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.

提交回复
热议问题