【问题标题】:page object file has become too large页面对象文件变得太大
【发布时间】:2022-06-30 21:23:42
【问题描述】:

我的页面对象文件已增长到超过 5000 行。我已将文件整理为login_screenlanding_screenprofile_screensettings_screen 等类。我正在考虑通过将每个类移动到自己的文件中来将文件拆分为多个文件。是否可以以这种方式拆分页面对象文件,而不必导入所有单个文件(包含每个类),而只需将基本页面导入到测试文件中,从而使所有类都可用。如果是,如何实施?我欢迎其他建议。请参阅以下页面对象文件中的类之一的示例:

class login_screen(BasePage):
    """login screen"""

    def __init__(self, driver):
        super().__init__(driver)

    def login_user(self, username, password):
    """Log in as an existing user"""

【问题讨论】:

    标签: python python-3.x appium pageobjects


    【解决方案1】:

    Unittest 已经为此提供了一个很好的解决方案,即测试发现。只需将其指向一个文件夹,它就会返回所有文件中的测试用例。

    unittest.defaultTestLoader.discover('/some/folder')
    

    【讨论】:

      猜你喜欢
      • 2017-02-09
      • 2020-03-17
      • 2014-10-29
      • 1970-01-01
      • 1970-01-01
      • 2010-12-22
      • 1970-01-01
      • 1970-01-01
      • 2019-04-14
      相关资源
      最近更新 更多